Skip to content

Commit 6b064d4

Browse files
authored
Create matrix-similarity-after-cyclic-shifts.cpp
1 parent 8d4f138 commit 6b064d4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Time: O(m * n)
2+
// Space: O(1)
3+
4+
// array
5+
class Solution {
6+
public:
7+
bool areSimilar(vector<vector<int>>& mat, int k) {
8+
for (const auto& row: mat) {
9+
for (int j = 0; j < size(row); ++j) {
10+
if (row[j] != row[(j + k) % size(row)]) {
11+
return false;
12+
}
13+
}
14+
}
15+
return true;
16+
}
17+
};

0 commit comments

Comments
 (0)