CodePudding user response:
Search for
in the upper rightPublic Boolean find (int num, int [] [] array) {
Int rows=array. The length;
If (rows==0) {
return false;
}
Int cols=array [0]. Length;
If (cols==0) {
return false;
}
//right
Int row=0;
Int col=cols - 1;
While (row=0) {
If (array [row] [col]Row++;
} else if (array [row] [col] & gt; Num) {
Col -;
} else {
return true;
}
}
return false;
}