Problem
You are given an m x n grid matrix where each row is sorted left to right and each column is sorted top to bottom. Unlike Search a 2D Matrix, a row can start below where the previous row ended, so the grid is not one sorted list. Return true if target is in the grid.
Example 1
matrix = [[1, 4, 7, 11, 15],
Example 2
[2, 5, 8, 12, 19],
Example 3
[3, 6, 9, 16, 22],
Example 4
[10, 13, 14, 17, 24],
Example 5
[18, 21, 23, 26, 30]]
Example 6
- Input
- target = 5
- Output
- true
Example 7
- Input
- target = 20
- Output
- false
Constraints
1 <= m, n <= 300-10^9 <= matrix[i][j], target <= 10^9Every row and every column is sorted in ascending order.