1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/托普利茨矩阵 [toeplitz-matrix].html
2022-03-29 12:43:11 +08:00

45 lines
1.6 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个 <code>m x n</code> 的矩阵 <code>matrix</code> 。如果这个矩阵是托普利茨矩阵,返回 <code>true</code> ;否则,返回<em> </em><code>false</code><em></em></p>
<p>如果矩阵上每一条由左上到右下的对角线上的元素都相同,那么这个矩阵是<em> </em><strong>托普利茨矩阵</strong></p>
<p> </p>
<p><strong>示例 1</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2020/11/04/ex1.jpg" style="width: 322px; height: 242px;" />
<pre>
<strong>输入:</strong>matrix = [[1,2,3,4],[5,1,2,3],[9,5,1,2]]
<strong>输出:</strong>true
<strong>解释:</strong>
在上述矩阵中, 其对角线为:
"[9]", "[5, 5]", "[1, 1, 1]", "[2, 2, 2]", "[3, 3]", "[4]"。
各条对角线上的所有元素均相同, 因此答案是 True 。
</pre>
<p><strong>示例 2</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2020/11/04/ex2.jpg" style="width: 162px; height: 162px;" />
<pre>
<strong>输入:</strong>matrix = [[1,2],[2,2]]
<strong>输出:</strong>false
<strong>解释:</strong>
对角线 "[1, 2]" 上的元素不同。</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>m == matrix.length</code></li>
<li><code>n == matrix[i].length</code></li>
<li><code>1 <= m, n <= 20</code></li>
<li><code>0 <= matrix[i][j] <= 99</code></li>
</ul>
<p> </p>
<p><strong>进阶:</strong></p>
<ul>
<li>如果矩阵存储在磁盘上,并且内存有限,以至于一次最多只能将矩阵的一行加载到内存中,该怎么办?</li>
<li>如果矩阵太大,以至于一次只能将不完整的一行加载到内存中,该怎么办?</li>
</ul>