Skip to content

Commit b921943

Browse files
authored
Create divide-array-into-increasing-sequences.py
1 parent 42624ca commit b921943

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
class Solution(object):
5+
def canDivideIntoSubsequences(self, nums, K):
6+
"""
7+
:type nums: List[int]
8+
:type K: int
9+
:rtype: bool
10+
"""
11+
curr, max_count = 1, 1
12+
for i in xrange(1, len(nums)):
13+
curr = 1 if nums[i-1] < nums[i] else curr+1
14+
max_count = max(max_count, curr)
15+
return K*max_count <= len(nums)

0 commit comments

Comments
 (0)