Search a 2D matrix II
Problem Search for a target in an m x n matrix where each row is sorted left-to-right and each column is sorted top-to-bottom.
Input / Output
- Input: matrix, target.
- Output: boolean (or the position).
Constraints
- m, n up to 300; O(m + n) expected.
Example
- [[1,4,7,11],[2,5,8,12],[3,6,9,16],[10,13,14,17]], target 5 -> true; target 20 -> false.
asked …