December 27, 2024 |3.5K Views

Search in a row - column wise sorted matrix

Explore Courseexplore course icon
Description
Discussion

To search for an element in a row-wise and column-wise sorted matrix, you can use two approaches. The naive approach involves traversing the entire matrix with a time complexity of O(n*m). The expected approach starts at the top-right corner and eliminates rows or columns based on comparisons, with a time complexity of O(n+m). For the input mat[][] = [[3, 30, 38], [20, 52, 54], [35, 60, 69]] and x = 35, the result is true. 

Read the full article for more details here.