Created
October 27, 2019 06:08
-
-
Save zew13/fcb64f77ded9cdace0455929b9ce0379 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 split(li): | |
| if not li: | |
| return | |
| t = [] | |
| min = li[-1] | |
| for i in reversed(li): | |
| if i < min: | |
| min = i | |
| t.append(min) | |
| t = t[::-1] | |
| for pos, i in enumerate(li): | |
| if i <= t[pos]: | |
| break | |
| print(li[:pos+1], li[pos+1:]) | |
| return pos+1 | |
| split([5, -2, 3, 8, 6]) | |
| split([-5, -5, -5, -42, 6, 12]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment