Search sorted matrix
Given an m x n integer matrix where each row is sorted ascending left-to-right and each column is sorted ascending top-to-bottom, determine whether a target value exists in the matrix. Return True or False. Aim for O(m + n) time. The matrix has at least one row and one column.
Implement
search_matrix_staircase(matrix: list[list[int]], target: int) → boolExamples
in
[[[1,4,7,11],[2,5,8,12],[3,6,9,16],[10,13,14,17]],5]outtrueWhat a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 20 min
solution.py
InputExpectedGot
[[[1,4,7,11],[2,5,8,12],[3,6,9,16],[10,13,14,17]],5]truenot run yetsample