Search sorted matrix
Given an m x n matrix where each row is sorted ascending left-to-right and the first integer of each row is greater than the last integer of the previous row (i.e. the matrix is fully sorted in row-major order), determine whether a target value exists. Return True or False. Do it in O(log(m*n)). Dimensions up to 100 x 100.
Implement
search_matrix(matrix: list[list[int]], target: int) → boolExamples
in
[[[1,3,5,7],[10,11,16,20],[23,30,34,60]],3]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,3,5,7],[10,11,16,20],[23,30,34,60]],3]truenot run yetsample