1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/二维数组中的查找 [er-wei-shu-zu-zhong-de-cha-zhao-lcof].html
2022-03-29 12:43:11 +08:00

34 lines
963 B
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.

<p>在一个 n * m 的二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个高效的函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。</p>
<p> </p>
<p><strong>示例:</strong></p>
<p>现有矩阵 matrix 如下:</p>
<pre>
[
[1, 4, 7, 11, 15],
[2, 5, 8, 12, 19],
[3, 6, 9, 16, 22],
[10, 13, 14, 17, 24],
[18, 21, 23, 26, 30]
]
</pre>
<p>给定 target = <code>5</code>,返回 <code>true</code></p>
<p>给定 target = <code>20</code>,返回 <code>false</code></p>
<p> </p>
<p><strong>限制:</strong></p>
<p><code>0 <= n <= 1000</code></p>
<p><code>0 <= m <= 1000</code></p>
<p> </p>
<p><strong>注意:</strong>本题与主站 240 题相同:<a href="https://leetcode-cn.com/problems/search-a-2d-matrix-ii/">https://leetcode-cn.com/problems/search-a-2d-matrix-ii/</a></p>