Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 36dc353

Browse files
authored
Create Matrix Similarity After Cyclic Shifts.java
1 parent 25c398f commit 36dc353

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public boolean areSimilar(int[][] mat, int k) {
3+
for (int j = 0; j < mat.length; j++) {
4+
if (j % 2 != 0) {
5+
continue;
6+
}
7+
int[] row = mat[j];
8+
int n = row.length;
9+
for (int i = 0; i < n; i++) {
10+
if (row[i] != row[(i + k) % n]) {
11+
return false;
12+
}
13+
}
14+
}
15+
return true;
16+
}
17+
}

0 commit comments

Comments
 (0)