Class Solution
java.lang.Object
g0201_0300.s0240_search_a_2d_matrix_ii.Solution
240 - Search a 2D Matrix II.<p>Medium</p>
<p>Write an efficient algorithm that searches for a <code>target</code> value in an <code>m x n</code> integer <code>matrix</code>. The <code>matrix</code> 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><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2020/11/24/searchgrid2.jpg" alt="" /></p>
<p><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</p>
<p><strong>Output:</strong> true</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2020/11/24/searchgrid.jpg" alt="" /></p>
<p><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</p>
<p><strong>Output:</strong> false</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>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
searchMatrix
public boolean searchMatrix(int[][] matrix, int target)
-