Loading...
You are given an m x n integer matrix matrix where every row is sorted in ascending order from left to right and every column is sorted in ascending order from top to bottom, plus an integer target.
Return true if target appears in the matrix, false otherwise.
You must write an algorithm that runs in O(m+n) time.
Input: matrix = [[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24],[18,21,23,26,30]], target = 5
Output: true
Input: matrix = [[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24],[18,21,23,26,30]], target = 20
Output: false
matrix.length, n= matrix[i].lengthmatrix[i][j], target ≤109Click "Run" to test with sample cases or "Submit" to run all tests.