dsa1 min read
Search a 2D Matrix — Treat as 1D Sorted Array
Search a row-column sorted 2D matrix in O(log(m*n)) by treating it as a virtual 1D sorted array.
Read →
webcoderspeed.com
3 articles
Search a row-column sorted 2D matrix in O(log(m*n)) by treating it as a virtual 1D sorted array.
Search a row-column sorted 2D matrix in O(m+n) using the staircase technique from top-right corner.
Count negatives in a sorted matrix in O(m+n) using the staircase approach or O(m log n) with binary search per row.