Skip to content

Commit 95601a4

Browse files
authored
Create 2811-check-if-it-is-possible-to-split-array.js
1 parent ba8ffa4 commit 95601a4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @param {number[]} nums
3+
* @param {number} m
4+
* @return {boolean}
5+
*/
6+
const canSplitArray = function(nums, m) {
7+
const n = nums.length
8+
if(n <= 2) return true
9+
for(let i = 1; i < n; i++) {
10+
if(nums[i] + nums[i - 1] >= m) return true
11+
}
12+
return false
13+
};

0 commit comments

Comments
 (0)