• 문제 링크
Toeplitz Matrix - LeetCode
Can you solve this real interview question? Toeplitz Matrix - Given an m x n matrix, return true if the matrix is Toeplitz. Otherwise, return false. A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same elements. Example 1:
leetcode.com
• 풀이 코드
public class Solution {
public boolean isToeplitzMatrix(int[][] matrix) {
int r = matrix.length, c = matrix[0].length;
for (int i = 1; i < r; i++) for (int j = 1; j < c; j++) if (matrix[i][j] != matrix[i - 1][j - 1]) return false;
return true;
}
}'Problem Solving > LeetCode' 카테고리의 다른 글
| [LeetCode] 783. Minimum Distance Between BST Nodes - Java (0) | 2026.10.14 |
|---|---|
| [LeetCode] 771. Jewels and Stones - Java (0) | 2026.10.13 |
| [LeetCode] 762. Prime Number of Set Bits in Binary Representation - Java (0) | 2026.10.11 |
| [LeetCode] 748. Shortest Completing Word - Java (0) | 2026.10.10 |
| [LeetCode] 747. Largest Number At Least Twice of Others - Java (0) | 2026.10.09 |
댓글