Problem of the day
1. In each row, integers are sorted from left to right.
2. Each row's first integer is greater than the previous row's last integer.
Input:
'MATRIX' = [ [1, 3, 5, 7], [10, 11, 16, 20], [23, 30, 34, 60] ], 'TARGET' = 3
Output:1
Explanation: Since the given number βTARGETβ is present in the matrix, we return true.
The first line of the input will contain two integers denoting the dimensions of the matrix βNβ and βMβ.
The following 'N' lines contain βMβ integers.
The next line contains an integer βTARGETβ.
The only line contains 1 if 'TARGET' is present otherwise, 0.
You donβt need to print anything. Just implement the given function.
3 3
1 3 7
10 12 15
19 20 21
12
1
Input:
'MATRIX' = [ [1, 3, 7], [10, 12, 15], [19, 20, 21] ], 'TARGET' = 12
Output: 1
Explanation: Since the given number βTARGETβ is present in the matrix, we return true.
4 4
1 5 9 13
14 15 16 17
19 20 21 50
59 60 71 80
80
1
1 <= 'N', 'M' <=10^5
1 <= 'MATRIX [ i ] [ j ]', 'TARGET' <= 10^9
The sum of N*M over all test cases is less than 2*10^5.
Time Limit: 1 sec