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

Method _decomposeAndMerge

Array/KthLargestElementInAnArray.py:103–122  ·  view source on GitHub ↗
(self, unsorted_list_A, unsorted_list_B, key)

Source from the content-addressed store, hash-verified

101 return self._decomposeAndMerge(left, right, key=key)
102
103 def _decomposeAndMerge(self, unsorted_list_A, unsorted_list_B, key):
104 sorted_list = []
105 a = 0
106 b = 0
107 length_A = len(unsorted_list_A)
108 length_B = len(unsorted_list_B)
109 while a < length_A and b < length_B:
110
111 if unsorted_list_A[a] <= unsorted_list_B[b]:
112 sorted_list.append(unsorted_list_A[a])
113 a += 1
114 else:
115 sorted_list.append(unsorted_list_B[b])
116 b += 1
117 if a < length_A:
118 sorted_list.extend(unsorted_list_A[a:])
119 else:
120 sorted_list.extend(unsorted_list_B[b:])
121
122 return sorted_list
123
124
125 def findKthLargest(self, nums, k):

Callers 1

mergeSortMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected