Advertisement
Guest User

Untitled

a guest
Jul 28th, 2020
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. def merge(A, B):
  2.     C = []
  3.     lenListA = len(A)
  4.     lenListB = len(B)
  5.     indexA = 0
  6.     indexB = 0
  7.     i = 0
  8.     while i < lenListA:
  9.         for j in range(indexB, lenListB):
  10.             if A[i] > B[j]:
  11.                 C.append(B[j])
  12.                 indexB += 1
  13.             else:
  14.                 C.append(A[i])
  15.                 indexA += 1
  16.                 break
  17.         i += 1
  18.     if indexA < lenListA:
  19.         C.append(A[indexA])
  20.     elif indexB < lenListB:
  21.         C.append(B[indexB])
  22.     return C
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement