Error in solution of java


#1

How can I return a triangular array in java? It is simply not possible. for example, according to question return should be [1 ] [1 1 ] [1 2 1 ] [1 3 3 1 ] [1 4 6 4 1 ] but since it is a double dimension array so I am returning [1 0 0 0 0 ] [1 1 0 0 0 ] [1 2 1 0 0 ] [1 3 3 1 0 ] [1 4 6 4 1 ] where 0’s are filled by JVM as its a default value.


#2

Yeah, you are correct, we cannot return a triangular array in java, that’s why the question needs ArrayList instead of array, where triangle shape is possible