Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4ccbde3

Browse files
2946. Matrix Similarity After Cyclic Shifts
1 parent 1ad8636 commit 4ccbde3

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution {
2+
3+
// Solution by Sergey Leschev
4+
// 2946. Matrix Similarity After Cyclic Shifts
5+
6+
// Time complexity: O (m * n)
7+
// Space complexity: O(1)
8+
9+
func areSimilar(_ mat: [[Int]], _ k: Int) -> Bool {
10+
for row in mat {
11+
let n = row.count
12+
for i in 0..<n {
13+
if row[i] != row[(i + k) % n] {
14+
return false
15+
}
16+
}
17+
}
18+
return true
19+
}
20+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /