Code RoomSearch sorted matrix
MediumPrep Room Coding #988

Search sorted matrix

CodingAlgorithms & data structuresMid–Senior~20 min

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) → bool
Examples
in[[[1,3,5,7],[10,11,16,20],[23,30,34,60]],3]outtrue
What 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
InputExpectedGot
[[[1,3,5,7],[10,11,16,20],[23,30,34,60]],3]truenot run yetsample