Not parsing corrctly 2D array

programming
Tags: #<Tag:0x00007f2427cd3960>

#1

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:

12
1213
13
[] [] [] []

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


#2

I am having the same issue.


#3

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.


#4

Try using arrayList of arrayLists.


#5

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.


#6

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


#7

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[][] …


#8

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