2811. Check if it is Possible to Split Array
You are given an array
nums
of lengthn
and an integerm
. You need to determine if it is possible to split the array inton
non-empty arrays by performing a series of steps.In each step, you can select an existing array (which may be the result of previous steps) with a length of at least two and split it into two subarrays, if, for each resulting subarray, at least one of the following holds:
- The length of the subarray is one, or
- The sum of elements of the subarray is greater than or equal to
m
.Return
true
if you can split the given array inton
arrays, otherwise returnfalse
.Note: A subarray is a contiguous non-empty sequence of elements within an array.
1 | class Solution { |