Split an array into k subarrays of sum s

I have an array of length N, let’s say something like:

4 6 4 6 4 6

I need to split this array into P subarrays (in this example, P=3 would be reasonable), such that the sum of the elements in each subarray is s(lets take s=10) : for this ans is {4,6} {4,6} {4,6}

but for this array

3 6 3 6 6 6

there is not any solution. So guys help me out please…

This query cannot be answered right now as this is from a question in the current long challenge.

You can read about it here.

1 Like

that asks for subsets not subarrays

but he has asked this question in relation to CodeChef: Practical coding for everyone problem!!