Search 2D sorted matrix
Your task
You are given an m x n matrix where each row is sorted ascending left-to-right and each column is sorted ascending top-to-bottom. Given a target, return [row, col] of an occurrence (0-indexed), or [-1, -1] if absent. Aim for O(m + n). Constraints: 1 <= m, n <= 300, -10^9 <= values, target <= 10^9.
Examples
search_sorted_matrix(matrix: list[list[int]], target: int) -> list[int]Example 1
Input
search_sorted_matrix([[1, 4, 7, 11], [2, 5, 8, 12], [3, 6, 9, 16], [10, 13, 14, 17]], 5)Output
[1, 1]