public class Solution {
public boolean Find(int target, int [][] array) {
int row,col,row_length,col_length;
row_length = array.length;
col_length = array[0].length;
row = row_length-1;
col = 0;
for(int i=0;i<row_length+col_length-2;i++){
if (target > array[row][col] && col < col_length-1){
col++;
continue;
}
if (target < array[row][col] && row > 0){
row--;
continue;
}
if (target == array[row][col]){
return true;
}
}
return false;
}
}
【剑指offer】判断mxn二维排序数组是否存在某值
最新推荐文章于 2025-08-05 15:09:30 发布