标签:dex targe return blog 数组 bounds i++ 排序 else
1 public class Solution { 2 public boolean Find(int target, int [][] array) { 3 boolean result = false; 4 if(array == null || array.length == 0) return false; 5 for(int i = 0; i < array.length; i++){ 6 if(array[i] == null || array[i].length == 0) return false; //防止ArrayIndexOutOfBoundsException 7 if(target >= array[i][0]){ 8 result = BinaraySearch(target,array[i],0,array[i].length); 9 } 10 if(result == true) return result; 11 } 12 return result; 13 } 14 public boolean BinaraySearch(int target, int[] array,int lo, int hi){ 15 if(lo >= hi) return false; 16 int mid = (lo + hi) / 2; 17 if(array[mid] == target) return true; 18 else if(array[mid] > target) return BinaraySearch(target, array, lo, mid); 19 else return BinaraySearch(target, array, mid + 1, hi); 20 } 21 }
标签:dex targe return blog 数组 bounds i++ 排序 else
原文地址:http://www.cnblogs.com/zhangcaiwang/p/6671835.html