Skip to content

Commit 298bd54

Browse files
array matrix copy of range
1 parent ee38603 commit 298bd54

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

convert-1d-array-into-2d-array.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,21 @@ public int[][] construct2DArray(int[] original, int m, int n) {
1010
return arr;
1111
}
1212
}
13+
// class Solution {
14+
// public int[][] construct2DArray(int[] original, int m, int n) {
15+
// if(m*n!=original.length){
16+
// return new int[0][0];
17+
// }
18+
// int ans[][]=new int[m][n];
19+
// int row=0;
20+
// int col=0;
21+
// for(int i=0;i<original.length;i++){
22+
// ans[row][col++]=original[i];
23+
// if(col==n){
24+
// col=0;
25+
// row++;
26+
// }
27+
// }
28+
// return ans;
29+
// }
30+
// }

0 commit comments

Comments
 (0)