Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kishan3/c4d6625a1aa0dc62e6d980cf9f37e362 to your computer and use it in GitHub Desktop.
Save kishan3/c4d6625a1aa0dc62e6d980cf9f37e362 to your computer and use it in GitHub Desktop.
# n = size of array1
# m = size of array2
def merge(array1, array2, n , m):
x = 0
y = 0
result = []
k = 0
while (x < n) and (y < m):
if array1[x] > array2[y]:
result.append(array1[x])
x+=1
else:
result.append(array2[y])
y+=1
while x < n:
result.append(array1[x])
x+=1
while y < m:
result.append(array2[y])
y+=1
for i in result:
print (i, end=" ")
print("")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment