Created
October 4, 2019 00:40
-
-
Save athulmurali/56111dd3a71408ab8921d1eedccf5d86 to your computer and use it in GitHub Desktop.
ShittyCode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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