Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def merge(A, B):
- C = []
- lenListA = len(A)
- lenListB = len(B)
- indexA = 0
- indexB = 0
- i = 0
- while i < lenListA:
- for j in range(indexB, lenListB):
- if A[i] > B[j]:
- C.append(B[j])
- indexB += 1
- else:
- C.append(A[i])
- indexA += 1
- break
- i += 1
- if indexA < lenListA:
- C.append(A[indexA])
- elif indexB < lenListB:
- C.append(B[indexB])
- return C
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement