Empresa engajada
Find a number in a matrix which is sorted by row and column
Sigiloso
The previous 2 solutions presented by other people are not complete. Check your solutions when the Matrix is 1,2,3,4 2.5,3.5,4.5,5.5 3.6,4.6,5.6,6.6 5.7,6.7,7.7,8.7 and the number to find is 4.6 The best solution is Start from the bottom left corner of the matrix. Compare the element with the number N If N is greater than the element then shift to right else shift Up. O(m+n) , Where m = Number of Rows, n = numer of columns An optimized version of this algorithm is start from the bottom left element and do binary search and shift by that amount rather than shifting by 1 O(log n + log m)