It is solvable. The kata just expects [] if the array is empty
and [[]] if the array only contains empty arrays.
so [[]] or [[],[]] would return [[]]
but [] would return []
I do however agree that this is an issue. The kata should either describe what to do in each case, or return the same value for an empty array and an array of empty arrays
OP solved it, closing
That was a common issue, the description would have helped.
Don't mutate the input.
It is solvable. The kata just expects [] if the array is empty
and [[]] if the array only contains empty arrays.
so [[]] or [[],[]] would return [[]]
but [] would return []
I do however agree that this is an issue. The kata should either describe what to do in each case, or return the same value for an empty array and an array of empty arrays
You need to think about optimizing the algorithm. A O(N^2) solution is too slow.
I'm having the same problem