Your question is Matrix Search Without Full Scan. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Hiver organizes illustrative thread-priority values in a matrix where every row and every column is sorted in ascending order. Given this matrix and a target priority, return the coordinates of any cell containing the target without scanning every cell.
Use an algorithm that exploits both sorting dimensions. Return [-1, -1] when the target is absent.
Implement search_priority_matrix(matrix, target), where matrix is a non-empty rectangular list of lists of integers and target is an integer. Return a two-element list [row_index, column_index]. If duplicate target values exist, any matching coordinate is valid.
def search_priority_matrix(matrix, target):