Skip to content

Commit f00e149

Browse files
authored
Create check-if-it-is-possible-to-split-array.py
1 parent fefed88 commit f00e149

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
# constructive algorithms
5+
class Solution(object):
6+
def canSplitArray(self, nums, m):
7+
"""
8+
:type nums: List[int]
9+
:type m: int
10+
:rtype: bool
11+
"""
12+
return len(nums) <= 2 or any(nums[i]+nums[i+1] >= m for i in xrange(len(nums)-1))

0 commit comments

Comments
 (0)