File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -310,6 +310,7 @@ mod prob_751;
310
310
mod prob_753;
311
311
mod prob_756;
312
312
mod prob_765;
313
+ mod prob_766;
313
314
mod prob_785;
314
315
mod prob_802;
315
316
mod prob_809;
Original file line number Diff line number Diff line change
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 ;
You can’t perform that action at this time.
0 commit comments