Skip to content

Instantly share code, notes, and snippets.

@ematta
Created February 9, 2020 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ematta/5127cfaa72bdba275e5bd5a07f7f39bc to your computer and use it in GitHub Desktop.
Save ematta/5127cfaa72bdba275e5bd5a07f7f39bc to your computer and use it in GitHub Desktop.
class Solution(object):
def partitionDisjoint(self, A):
"""
:type A: List[int]
:rtype: int
"""
if not A:
return 0
left = A[:1]
right = A[1:]
for _ in range(1, len(A)):
if max(left) <= min(right):
break
else:
left.append(right[0])
del right[0]
return(len(left))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment