// Method 1: Starting from the number in the upper right corner is the initial point of judgment
function Find(target, array)
{
// write code here
var row = array.length;
var col = array[0].length;
var i =0 ;
var j = col-1;
while(i < row && j>=0){
if(array[i][j]>target){
j--;
continue;
}else if(array[i][j]<target){
i++;
continue;
}else{
//return true;
console.log("The rows and columns where this number is:", i,j);
}
return false;
}
}
// Method 1: Starting from the number in the lower left corner is the initial point of judgment
function Find(target, array)
{
var row=array.length,
col=array[0].length,
i=row-1,
j=0;
while(i>=0&&j<col){
if(array[i][j]>target){
i--;
continue;
}else if(array[i][j]<target){
j++;
continue;
}else{
//return true;
console.log("The rows and columns where this number is:", i,j);
break;
}
return false;
}
}
var arr= [[1,2,3],[2,3,5],[3,6,9]];
Find(6,arr); //The rows and columns of this number are: 2 1