Skip to content

Instantly share code, notes, and snippets.

@zew13
Created October 27, 2019 06:08
Show Gist options
  • Select an option

  • Save zew13/fcb64f77ded9cdace0455929b9ce0379 to your computer and use it in GitHub Desktop.

Select an option

Save zew13/fcb64f77ded9cdace0455929b9ce0379 to your computer and use it in GitHub Desktop.
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