Given an array and a 2d matrix. You have to find if the array is present in the matrix or not.To do so, you can start from any point in the matrix and go in 4 directions that is if you are at (i,j) you can go to (i+1,j), (i-1,j), (i,j+1), (i,j-1).
Return the starting and ending pairs of indices if the array exists otherwise return false.
Suppose the given array is [ 1, 10, 22, 47, 33, 10] and the matrix is as given below..then as we can see the array exists in the matrix and the starting and ending points respectively are: (2,2) and (3,4) [ 0-based indexing]
What will be the efficient solution ,i mean what will be the time complexity ?