Not parsing corrctly 2D array

Tags: #<Tag:0x00007f2427cd3960>


When I am printing just before returning the 2-D array, it has the element in the array but after returning it show empty 2-D array.

For Input:
A : [ 12, 13 ]

Your function returned the following output with Print Statement:

[] [] [] []

Your function returned the following output without Print Statement:
[] [] [] []


I am having the same issue.


Did anybody find what the problem is ?
I am also facing the same issue.
It is working properly when i run it locally on my system.


Try using arrayList of arrayLists.


when you are adding your subset to final 2D arraylist -> add it as new ArrayList. The problem of all values being null is because it stores the reference to subset which at the end is null. Adding it as new array solves the issue.


He is asking about 2d Array . Could you check for same because AFAIK your solution is for ArrayList. Right?


I’m having the exact issue, the output generated in debugger is perfect where as the 2D array in IB prints as [][]…[] and hence unable to submit.

Am using ArrayList<ArrayList> and then generating the int[][] …


I have been facing this issue in all the questions,where the return type is an 2D Array