Created
March 14, 2017 14:17
-
-
Save peroon/d9a009a9d8ff0a1de46471887013819c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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