Solution: Search in Sorted Matrix
Understand different methods for searching a target in a sorted 2D matrix. Learn a brute force linear search, a more efficient directional approach, and a binary search strategy, along with their time complexities to improve algorithmic problem solving.
Solution #1: Brute force
This is a simple linear search of a 2-D matrix. We use two for loops to iterate over the entire matrix and see if a value equal to the given target is found (lines 3-6).
Time complexity
Since we use two nested for loops, the time complexity is ...