Skip to content

Commit 975f92f

Browse files
committed
766
1 parent aece3d3 commit 975f92f

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ mod prob_751;
310310
mod prob_753;
311311
mod prob_756;
312312
mod prob_765;
313+
mod prob_766;
313314
mod prob_785;
314315
mod prob_802;
315316
mod prob_809;

src/prob_766.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
impl Solution {
2+
pub fn is_toeplitz_matrix(matrix: Vec<Vec<i32>>) -> bool {
3+
let n = matrix.len();
4+
if n == 0 {
5+
return false;
6+
}
7+
let m = matrix[0].len();
8+
for i in 0..n-1 {
9+
let t = matrix[i][0];
10+
let (mut x, mut y) = (i,0);
11+
while x < n && y < m {
12+
if matrix[x][y] != t {
13+
return false;
14+
}
15+
x+=1;
16+
y+=1;
17+
}
18+
}
19+
for i in 1..m-1 {
20+
let t = matrix[0][i];
21+
let (mut x, mut y) = (0,i);
22+
while x < n && y < m {
23+
if matrix[x][y] != t {
24+
return false;
25+
}
26+
x+=1;
27+
y+=1;
28+
}
29+
}
30+
true
31+
}
32+
}
33+
34+
struct Solution;

0 commit comments

Comments
 (0)