GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — leetcode-algorithms/src/ReshapeTheMatrix.java at master · anishLearnsToCode/leetcode-algorithms Expand file tree/ Copy pathReshapeTheMatrix.javaMore file actions 13 lines (12 loc) · 461 Bytes / Copy pathReshapeTheMatrix.javaFile metadata and controls13 lines (12 loc) · 461 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 public class ReshapeTheMatrix { public int[][] matrixReshape(int[][] mat, int r, int c) { if (r * c != mat.length * mat[0].length || (mat.length == r && mat[0].length == c)) return mat; int[][] result = new int[r][c]; for (int i = 0, k = 0 ; i < mat.length ; i++) { for (int j = 0 ; j < mat[0].length ; j++, k++) { result[k / c][k % c] = mat[i][j]; } } return result; } } |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |