dsa · medium
Search a 2D Matrix II
Each row **and** each column is sorted ascending. Return whether target is present.
Arguments
matrix— the 2D grid / matrixtarget— the value you are searching for or summing to
Example
`` Input: [[1,4,7,11],[2,5,8,12],[3,6,9,16],[10,13,14,17]] 5 Output: true ``
Constraints
1 <= m, n <= 100 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.
Examples
Example 1
Input: [[1,4,7,11],[2,5,8,12],[3,6,9,16],[10,13,14,17]] 5 Expected: true
Example 2
Input: [[1,4,7,11],[2,5,8,12],[3,6,9,16],[10,13,14,17]] 20 Expected: false