carloscn / carloscn/structstudy

leetcode766:托普利茨矩阵(toeplitz_matrix_766)

Open
#130 2 comments 0 reactions 1 assignee Claimed by @carloscn View on GitHub
Level-easy 一般问题 数组 查找
Dominant language
C
Stars
4
Forks
1
PR merge metrics
No merged PRs in 30d

Description

### 问题分析

给你一个 m x n 的矩阵 matrix 。如果这个矩阵是托普利茨矩阵,返回 true ;否则,返回 false 。

如果矩阵上每一条由左上到右下的对角线上的元素都相同,那么这个矩阵是 托普利茨矩阵 。

示例 1:
![image](https://user-images.githubusercontent.com/16836611/220792179-80080fa9-21c2-4555-b5b8-adaac4f80e7f.png)

输入:matrix = [[1,2,3,4],[5,1,2,3],[9,5,1,2]]
输出:true
解释:
在上述矩阵中, 其对角线为:
"[9]", "[5, 5]", "[1, 1, 1]", "[2, 2, 2]", "[3, 3]", "[4]"。
各条对角线上的所有元素均相同, 因此答案是 True 。

示例 2:

![image](https://user-images.githubusercontent.com/16836611/220792255-3c32896f-7772-439b-951a-2b15c54b2403.png)

输入:matrix = [[1,2],[2,2]]
输出:false
解释:
对角线 "[1, 2]" 上的元素不同。
 

提示:

m == matrix.length
n == matrix[i].length
1 <= m, n <= 20
0 <= matrix[i][j] <= 99
 
进阶:

如果矩阵存储在磁盘上,并且内存有限,以至于一次最多只能将矩阵的一行加载到内存中,该怎么办?
如果矩阵太大,以至于一次只能将不完整的一行加载到内存中,该怎么办?

来源:力扣(LeetCode)
链接:https://leetcode.cn/problems/toeplitz-matrix
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.