Created
January 29, 2012 13:56
-
-
Save hodbby/1698934 to your computer and use it in GitHub Desktop.
Google 10 rows solution
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 linear_merge(list1, list2): | |
result = [] | |
while len(list1) and len(list2): | |
if list1[0] < list2[0]: | |
result.append(list1.pop(0)) | |
else: | |
result.append(list2.pop(0)) | |
result.extend(list1) | |
result.extend(list2) | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment