aboutsummaryrefslogtreecommitdiff
path: root/toeplitz_matrix.rs
diff options
context:
space:
mode:
authorjack <[email protected]>2024-06-14 13:13:15 -0600
committerjack <[email protected]>2024-06-14 13:13:15 -0600
commitd343a3b18dbaca9297d4f7b2280c4a16f0a5c8aa (patch)
tree96df922dae2a5073d9a50ea70c7aae6aa37e3ebe /toeplitz_matrix.rs
downloadleetcode-d343a3b18dbaca9297d4f7b2280c4a16f0a5c8aa.tar.gz
leetcode-d343a3b18dbaca9297d4f7b2280c4a16f0a5c8aa.zip
initial
Diffstat (limited to 'toeplitz_matrix.rs')
-rw-r--r--toeplitz_matrix.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/toeplitz_matrix.rs b/toeplitz_matrix.rs
new file mode 100644
index 0000000..03a46bb
--- /dev/null
+++ b/toeplitz_matrix.rs
@@ -0,0 +1,22 @@
+struct Solution;
+
+impl Solution {
+ pub fn is_toeplitz_matrix(matrix: Vec<Vec<i32>>) -> bool {
+ let (m, n) = (matrix.len(), matrix[0].len());
+ for i in 1..m {
+ for j in 1..n {
+ if matrix[i][j] != matrix[i - 1][j - 1] {
+ return false;
+ }
+ }
+ }
+ true
+ }
+}
+
+fn main() {
+ let matrix = vec![vec![1,2,3,4],
+ vec![5,1,2,3],
+ vec![9,5,1,2]];
+ print!("{}", Solution::is_toeplitz_matrix(matrix));
+}