MCPcopy Create free account
hub / github.com/careercup/ctci / matricesAreEqual

Method matricesAreEqual

java/Chapter 1/Question1_7/Question.java:102–115  ·  view source on GitHub ↗
(int[][] m1, int[][] m2)

Source from the content-addressed store, hash-verified

100 }
101
102 public static boolean matricesAreEqual(int[][] m1, int[][] m2) {
103 if (m1.length != m2.length || m1[0].length != m2[0].length) {
104 return false;
105 }
106
107 for (int k = 0; k < m1.length; k++) {
108 for (int j = 0; j < m1[0].length; j++) {
109 if (m1[k][j] != m2[k][j]) {
110 return false;
111 }
112 }
113 }
114 return true;
115 }
116
117 public static int[][] cloneMatrix(int[][] matrix) {
118 int[][] c = new int[matrix.length][matrix[0].length];

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected