1 2 8 9
2 4 9 12
4 7 10 13
6 8 11 15
/*
解题思路,这道题本质上是把二分法一维的变成了二维的
*/
let arr=[[1,2,8,9],[2,4,9,12],[4,7,10,13],[6,8,11,15]];
console.log(arr[3][3]);
function Find(target, array)
{
let ret=false;
let start=0;
let end=array.length;
let mid=0;
for(let i=0;i<array.length;i++){
start=0;
end=array[i].length-1;
while(start<=end){
mid=Math.floor((start+end)/2)
if(target>array[i][mid]){
start=mid+1;
}else if(target<array[i][mid]){
end=mid-1;
}else{
return true;
}
}
}
}