1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 19:18:14 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/最长递增路径 [fpTFWP].html

47 lines
1.7 KiB
HTML
Raw Normal View History

2022-03-27 20:38:29 +08:00
<p>给定一个&nbsp;<code>m x n</code> 整数矩阵&nbsp;<code>matrix</code> ,找出其中 <strong>最长递增路径</strong> 的长度。</p>
<p>对于每个单元格,你可以往上,下,左,右四个方向移动。 <strong>不能</strong><strong>对角线</strong> 方向上移动或移动到 <strong>边界外</strong>(即不允许环绕)。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2021/01/05/grid1.jpg" style="width: 242px; height: 242px;" /></p>
<pre>
<strong>输入:</strong>matrix = [[9,9,4],[6,6,8],[2,1,1]]
<strong>输出:</strong>4
<strong>解释:</strong>最长递增路径为&nbsp;<code>[1, 2, 6, 9]</code></pre>
<p><strong>示例 2</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2021/01/27/tmp-grid.jpg" style="width: 253px; height: 253px;" /></p>
<pre>
<strong>输入:</strong>matrix = [[3,4,5],[3,2,6],[2,2,1]]
<strong>输出:</strong>4
<strong>解释:</strong>最长递增路径是&nbsp;<code>[3, 4, 5, 6]</code>。注意不允许在对角线方向上移动。
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>matrix = [[1]]
<strong>输出:</strong>1
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>m == matrix.length</code></li>
<li><code>n == matrix[i].length</code></li>
<li><code>1 &lt;= m, n &lt;= 200</code></li>
<li><code>0 &lt;= matrix[i][j] &lt;= 2<sup>31</sup> - 1</code></li>
</ul>
<p>&nbsp;</p>
<p><meta charset="UTF-8" />注意:本题与主站 329&nbsp;题相同:&nbsp;<a href="https://leetcode-cn.com/problems/longest-increasing-path-in-a-matrix/">https://leetcode-cn.com/problems/longest-increasing-path-in-a-matrix/</a></p>