矩阵是有序的,从左下角来看,向上数字递减,向右数字递增,因此从左下角开始查找,
当要查找数字比左下角数字大时,右移,要查找数字比左下角数字小时,上移
function Find (array, target) {
let row = array.lenghth //行
let col = array[0].lenghth //列
for (let i = row -1, j = 0; i >= 0 && j < col){
if(target == array[i][j]) {
return true
}
if(target < array[i][j]) {
i--
continue
}
if(target >array[i][j]) {
j++
continue
}
}
return false
}