File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * 766. Toeplitz Matrix
3
+ * https://leetcode.com/problems/toeplitz-matrix/
4
+ * Difficulty: Easy
5
+ *
6
+ * Given an m x n matrix, return true if the matrix is Toeplitz. Otherwise, return false.
7
+ *
8
+ * A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same elements.
9
+ */
10
+
11
+ /**
12
+ * @param {number[][] } matrix
13
+ * @return {boolean }
14
+ */
15
+ function isToeplitzMatrix ( matrix ) {
16
+ const rows = matrix . length ;
17
+ const cols = matrix [ 0 ] . length ;
18
+
19
+ for ( let r = 0 ; r < rows - 1 ; r ++ ) {
20
+ for ( let c = 0 ; c < cols - 1 ; c ++ ) {
21
+ if ( matrix [ r ] [ c ] !== matrix [ r + 1 ] [ c + 1 ] ) {
22
+ return false ;
23
+ }
24
+ }
25
+ }
26
+
27
+ return true ;
28
+ }
Original file line number Diff line number Diff line change 580
580
763|[ Partition Labels] ( ./0763-partition-labels.js ) |Medium|
581
581
764|[ Largest Plus Sign] ( ./0764-largest-plus-sign.js ) |Medium|
582
582
765|[ Couples Holding Hands] ( ./0765-couples-holding-hands.js ) |Hard|
583
+ 766|[ Toeplitz Matrix] ( ./0766-toeplitz-matrix.js ) |Easy|
583
584
783|[ Minimum Distance Between BST Nodes] ( ./0783-minimum-distance-between-bst-nodes.js ) |Easy|
584
585
784|[ Letter Case Permutation] ( ./0784-letter-case-permutation.js ) |Medium|
585
586
790|[ Domino and Tromino Tiling] ( ./0790-domino-and-tromino-tiling.js ) |Medium|
You can’t perform that action at this time.
0 commit comments