Problem Description
Given a matrix of integers A of size N x M and an integer B. Write an efficient algorithm that searches for integer B in matrix A.
This matrix A has the following properties:
Return 1 if B is present in A, else return 0.
NOTE: Rows are numbered from top to bottom, and columns are from left to right.
1 <= N, M <= 1000
1 <= A[i][j], B <= 106
The first argument given is the integer matrix A.
The second argument given is the integer B.
Return 1 if B is present in A else, return 0.
Input 1:
A = [ [1, 3, 5, 7] [10, 11, 16, 20] [23, 30, 34, 50]
] B = 3
Input 2:
A = [
[5, 17, 100, 111] [119, 120, 127, 131]
] B = 3
Output 1:
1
Output 2:
0
Explanation 1:
3 is present in the matrix at A[0][1] position so return 1.
Explanation 2:
3 is not present in the matrix so return 0.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.