mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 15:31:43 +08:00
update
This commit is contained in:
34
leetcode/problem/search-a-2d-matrix-ii.html
Normal file
34
leetcode/problem/search-a-2d-matrix-ii.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<p>Write an efficient algorithm that searches for a value <code>target</code> in an <code>m x n</code> integer matrix <code>matrix</code>. This matrix has the following properties:</p>
|
||||
|
||||
<ul>
|
||||
<li>Integers in each row are sorted in ascending from left to right.</li>
|
||||
<li>Integers in each column are sorted in ascending from top to bottom.</li>
|
||||
</ul>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
<img alt="" src="https://assets.leetcode.com/uploads/2020/11/24/searchgrid2.jpg" style="width: 300px; height: 300px;" />
|
||||
<pre>
|
||||
<strong>Input:</strong> matrix = [[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]], target = 5
|
||||
<strong>Output:</strong> true
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
<img alt="" src="https://assets.leetcode.com/uploads/2020/11/24/searchgrid.jpg" style="width: 300px; height: 300px;" />
|
||||
<pre>
|
||||
<strong>Input:</strong> matrix = [[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]], target = 20
|
||||
<strong>Output:</strong> false
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>m == matrix.length</code></li>
|
||||
<li><code>n == matrix[i].length</code></li>
|
||||
<li><code>1 <= n, m <= 300</code></li>
|
||||
<li><code>-10<sup>9</sup> <= matrix[i][j] <= 10<sup>9</sup></code></li>
|
||||
<li>All the integers in each row are <strong>sorted</strong> in ascending order.</li>
|
||||
<li>All the integers in each column are <strong>sorted</strong> in ascending order.</li>
|
||||
<li><code>-10<sup>9</sup> <= target <= 10<sup>9</sup></code></li>
|
||||
</ul>
|
Reference in New Issue
Block a user