MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / merge_sort

Method merge_sort

Sorted/SortList.py:131–158  ·  view source on GitHub ↗
(l, r)

Source from the content-addressed store, hash-verified

129
130
131 def merge_sort(l, r):
132
133 _l = 0
134 _r = 0
135
136 _l_length = len(l)
137 _r_length = len(r)
138
139 result = []
140
141 while _l < _l_length and _r < _r_length:
142 if l[_l] < r[_r]:
143 result.append(l[_l])
144 _l += 1
145 else:
146 result.append(r[_r])
147 _r += 1
148
149 if _l == _l_length:
150 while _r < _r_length:
151 result.append(r[_r])
152 _r += 1
153 else:
154 while _l < _l_length:
155 result.append(l[_l])
156 _l += 1
157
158 return result
159
160 def split(l):
161 if len(l) <= 1:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected