Skip to content

Instantly share code, notes, and snippets.

@athulmurali
Created October 4, 2019 00:40
Show Gist options
  • Save athulmurali/56111dd3a71408ab8921d1eedccf5d86 to your computer and use it in GitHub Desktop.
Save athulmurali/56111dd3a71408ab8921d1eedccf5d86 to your computer and use it in GitHub Desktop.
ShittyCode
def merge_arr(a, b):
result = []
i = 0
j = 0
while i < len(a) or j < len(b):
if i < len(a) and ((j < len(b) and a[i] < b[j]) or j >= len(b)):
result.append(a[i])
i += 1
if j < len(b) and ((i < len(a) and b[j] <= a[i]) or i >= len(a)):
result.append(b[j])
j += 1
return result
a = [1,2,2,3]
b = [4]
print(merge_arr(a,b))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment