FourKites can represent shipment records in a matrix ordered by increasing tracking priority. Each row is sorted in nondecreasing order, and the first value in every row is greater than the last value in the previous row. Implement search_2d_matrix(matrix, target) to determine whether target exists.
Your algorithm must run in O(log(m × n)) time, where m is the number of rows and n is the number of columns. Treat the matrix as one sorted array without creating a flattened copy.
matrix, a rectangular list of lists containing integers, and target, an integer.True if target appears in the matrix; otherwise return False.False.def search_2d_matrix(matrix, target):