Skip to content

Commit

Permalink
Partition Array into Disjoint Intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
rinwf committed Sep 30, 2018
1 parent 766b947 commit ed97edc
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lc915. Partition Array into Disjoint Intervals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Solution:
def partitionDisjoint(self, A):
"""
:type A: List[int]
:rtype: int
"""
res = 1
tem = ma = A[0]
for i, x in enumerate(A):
if x < ma:
res = i + 1
ma = tem
else:
if tem < x:
tem = x
return res


A = [24, 11, 49, 80, 63, 8, 61, 22, 73, 85]
s = Solution()
print(s.partitionDisjoint(A))

0 comments on commit ed97edc

Please sign in to comment.