Java7 int[][] has a bug!?


#1

The output expects to be a multi dimensional array of primitive type. which is filled by 0’s

public class Solution {
public int[][] solve(int A) {
int[][] mat = new int[A][A];
for(int i=0;i<A;i++) {
for(int j=0;j<=i;j++)
{
if(i==0 && j==0) {
mat[i][j]=1;
} else if (j==0) {
mat[i][j] = mat[i-1][j];
} else {
mat[i][j] = mat[i-1][j]+ mat[i-1][j-1];
}
}
}
return mat;
}
}