65. Search in Sorted Grid
Medium
Each row of grade is sorted from left to right, and the first value of each row is greater than the last value of the previous row. Return true if alvo appears in the grid and false otherwise.
Example 1
Input: grade = [[1,4,7],[10,13,16],[20,25,30]], alvo = 13
Output: true
Example 2
Input: grade = [[1,4,7],[10,13,16],[20,25,30]], alvo = 8
Output: false
Constraints
- 1 <= quantidade de linhas, colunas <= 200
- Todas as linhas têm o mesmo tamanho
- -100000 <= valores e alvo <= 100000
Binary searchMatrix
Saved in this browser
Caso 1
grade =
[[1,4,7],[10,13,16],[20,25,30]]
alvo =
13
Expected =
true
Caso 2
grade =
[[1,4,7],[10,13,16],[20,25,30]]
alvo =
8
Expected =
false
Run checks these 2 cases. Submit runs all 7, including hidden ones.