Understanding the problem
2D binary search is probably the best algorithm for searching a sorted matrix. However, it only works when the conditions mentioned below are fulfilled for the input.
- Each row is sorted in ascending order
- The first element of each row is greater than the last element of the previous row.
However, in practice, data is often only partially sorted.
Liking the course? Check our discounted plans to continue learning.