Check if it is Possible to Split Array - Practice Coding | SlaveCode
0
0123456789
0
0123456789
:
0
0123456789
0
0123456789
2811. Check if it is Possible to Split Array
Medium
30 Points
Array
Dynamic Programming
Greedy
You are given an array nums of length n and an integer m. You need to determine if it is possible to split the array into n arrays of size 1 by performing a series of steps.
An array is called good if:
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 arrays, if both resulting arrays are good.
Return true if you can split the given array into n arrays, otherwise return false.
Input: nums = [2, 1, 3], m = 5
Output: false
Explanation:
The first move has to be either of the following:
So as both moves are invalid (they do not divide the array into two good arrays), we are unable to split nums into n arrays of size 1.
You are given an array nums of length n and an integer m. You need to determine if it is possible to split the array into n arrays of size 1 by performing a series of steps.
An array is called good if:
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 arrays, if both resulting arrays are good.
Return true if you can split the given array into n arrays, otherwise return false.
Input: nums = [2, 1, 3], m = 5
Output: false
Explanation:
The first move has to be either of the following:
So as both moves are invalid (they do not divide the array into two good arrays), we are unable to split nums into n arrays of size 1.