Skip to content

Commit 05f1544

Browse files
authored
Create 1121-divide-array-into-increasing-sequences.js
1 parent 05b456f commit 05f1544

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @param {number[]} nums
3+
* @param {number} K
4+
* @return {boolean}
5+
*/
6+
const canDivideIntoSubsequences = function (nums, K) {
7+
let cur = 1,
8+
groups = 1,
9+
n = nums.length
10+
for (let i = 1; i < n; ++i) {
11+
cur = nums[i - 1] < nums[i] ? 1 : cur + 1
12+
groups = Math.max(groups, cur)
13+
}
14+
return n >= K * groups
15+
}

0 commit comments

Comments
 (0)