Search A 2d Matrix

medium
1. Write an efficient algorithm that searches for a value in a m x n matrix. This matrix has the following properties:
a). Integers in each row are sorted from left to right.
b). The first integer of each row is greater than the last integer of the previous row.

Input Format

Input is managed for you

Output Format

Output is managed for you

Constraints

m == matrix.length
n == matrix[i].length
1 <= m, n <= 100
-10^4 <= matrix[i][j], target <= 10^4

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
5 4
1 3 5 7
10 11 16 20
23 30 34 60
62 63 65 68
71 72 74 80
65
Output
true
Previous
Union Of Two Sorted Arrays
Next
Search A 2d Matrix - 2

Related Questions