File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# LeetCode Algorithms
22
3- ![ problems-solved] ( https://img.shields.io/badge/Problems%20Solved-183 /2081-1f425f.svg )
4- ![ problems-solved-java] ( https://img.shields.io/badge/Java-183 /2081-1abc9c.svg )
5- ![ problems-solved-python] ( https://img.shields.io/badge/Python-183 /2081-1abc9c.svg )
3+ ![ problems-solved] ( https://img.shields.io/badge/Problems%20Solved-185 /2081-1f425f.svg )
4+ ![ problems-solved-java] ( https://img.shields.io/badge/Java-185 /2081-1abc9c.svg )
5+ ![ problems-solved-python] ( https://img.shields.io/badge/Python-185 /2081-1abc9c.svg )
66[ ![ PRs Welcome] ( https://img.shields.io/badge/PRs-welcome-brightgreen.svg )] ( CONTRIBUTING.md )
77[ ![ cp] ( https://img.shields.io/badge/also%20see-Competitve%20Programming-1f72ff.svg )] ( https://github.com/anishLearnsToCode/competitive-programming )
88
210210| 758 | [ Bold Words in String] ( https://leetcode.com/problems/bold-words-in-string ) | |
211211| 760 | [ Find Anagram Mappings] ( https://leetcode.com/problems/find-anagram-mappings ) | |
212212| 762 | [ Prime Number of Set Bits in Primary Representation] ( https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation ) | [ ![ Java] ( assets/java.png )] ( src/PrimeNumberOfSetBitsInBinaryRepresentation.java ) [ ![ Python] ( assets/python.png )] ( python/prime_number_of_set_bits_in_binary_representation.py ) |
213- | 766 | [ Toeplitz Matrix] ( https://leetcode.com/problems/toeplitz-matrix ) | |
213+ | 766 | [ Toeplitz Matrix] ( https://leetcode.com/problems/toeplitz-matrix ) | [ ![ Java ] ( assets/java.png )] ( src/ToeplitzMatrix.java ) [ ![ Python ] ( assets/python.png )] ( python/toeplitz_matrix.py ) |
214214| 771 | [ Jewels and Stones] ( https://leetcode.com/problems/jewels-and-stones ) | |
215215| 783 | [ Minimum Distance Between BST Nodes] ( https://leetcode.com/problems/minimum-distance-between-bst-nodes ) | [ ![ Java] ( assets/java.png )] ( src/MinimumAbsoluteDifferenceInBST.java ) [ ![ Python] ( assets/python.png )] ( python/minimum_distance_between_bst_nodes.py ) |
216216| 788 | [ Rotated Digits] ( https://leetcode.com/problems/rotated-digits ) | |
Original file line number Diff line number Diff line change 1+ from typing import List
2+
3+
4+ class Solution :
5+ def isToeplitzMatrix (self , matrix : List [List [int ]]) -> bool :
6+ columns , rows = len (matrix [0 ]), len (matrix )
7+ for column in range (columns - 1 ):
8+ current = matrix [0 ][column ]
9+ for row in range (1 , rows ):
10+ if column + row >= columns :
11+ break
12+ if matrix [row ][column + row ] != current :
13+ return False
14+ for row in range (1 , rows - 1 ):
15+ current = matrix [row ][0 ]
16+ for column in range (1 , columns ):
17+ if row + column >= rows :
18+ break
19+ if matrix [row + column ][column ] != current :
20+ return False
21+ return True
Original file line number Diff line number Diff line change 1+ public class ToeplitzMatrix {
2+ public boolean isToeplitzMatrix (int [][] matrix ) {
3+ final int rows = matrix .length , columns = matrix [0 ].length ;
4+ int current ;
5+ for (int column = 0 ; column < columns ; column ++) {
6+ current = matrix [0 ][column ];
7+ for (int row = 1 ; row < rows && column + row < columns ; row ++) {
8+ if (matrix [row ][column + row ] != current ) return false ;
9+ }
10+ }
11+ for (int row = 1 ; row < rows - 1 ; row ++) {
12+ current = matrix [row ][0 ];
13+ for (int column = 1 ; column < columns && row + column < rows ; column ++) {
14+ if (matrix [row + column ][column ] != current ) return false ;
15+ }
16+ }
17+ return true ;
18+ }
19+ }
You can’t perform that action at this time.
0 commit comments