Skip to content

Instantly share code, notes, and snippets.

@peroon
Created March 14, 2017 14:17
Show Gist options
  • Select an option

  • Save peroon/d9a009a9d8ff0a1de46471887013819c to your computer and use it in GitHub Desktop.

Select an option

Save peroon/d9a009a9d8ff0a1de46471887013819c to your computer and use it in GitHub Desktop.
def test():
A = [5,2,4,6,1,3]
print(A)
for i in range(1, len(A)):
print('A', A)
v = A[i]
# search insert position
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(A)
if __name__ == '__main__':
test()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment