题解 | #二维数组中的查找#
二维数组中的查找
https://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e
public class Solution { public boolean Find(int target, int [][] array) { //便利二维数组 for(int i = 0 ; i < array.length ; i++ ){ int newArray[] = array[i]; //判读是否存在目标数的有则返回true if(isExtis(newArray,target)){ return true; } } return false; } //二分寻找目标数 public boolean isExtis(int[] array,int target){ int left = 0 ; int right = array.length - 1; int mid = 0; while(left <= right){ mid = (left + right) /2; if(array[mid] < target) left = mid + 1; else if(array[mid] > target) right = mid - 1; else return true; } return false; } }