Search a matrix sorted in row-major order
Your task
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.
Examples
search_matrix(matrix: list[list[int]], target: int) -> boolExample 1
Input
search_matrix([[1, 3, 5, 7], [10, 11, 16, 20], [23, 30, 34, 60]], 3)Output
True