@Test void find() { Random random = new Random(); inputs.forEach(array -> { int randomInt = random.nextInt(40)*10; boolean reault = SearchInDoubleDimArray.findByBinarySearch(randomInt,array); System.out.println(randomInt + " result " + reault); }); }
public static boolean findByBinarySearch(int target, int [][] array) { if (array.length <= 0){ return false; } if (array[0].length <= 0){ return false; } int rowSize = array.length; int rankSize = array[0].length; if (target < array[0][0] || target > array[rowSize-1][rankSize-1]){ return false; } AtomicBoolean result = new AtomicBoolean(false); Arrays.stream(array).forEach(row -> { if (Arrays.binarySearch(row,target) >= 0){ result.set(true); } }); return result.get(); }
SearchInDoubleDimArray { public static boolean findByBinarySearch(int target, int [][] array) { if (array.length <= 0){ return false; } if (array[0].length <= 0){ return false; } int rowSize = array.length; int rankSize = array[0].length; if (target < array[0][0] || target > array[rowSize-1][rankSize-1]){ return false; } AtomicBoolean result = new AtomicBoolean(false); Arrays.stream(array).forEach(row -> { if (Arrays.binarySearch(row,target) >= 0){ result.set(true); } }); return result.get(); } }
SearchInDoubleDimArray { public static boolean findByBinarySearch(int target, int [][] array) { if (array.length <= 0){ return false; } if (array[0].length <= 0){ return false; } int rowSize = array.length; int rankSize = array[0].length; if (target < array[0][0] || target > array[rowSize-1][rankSize-1]){ return false; } AtomicBoolean result = new AtomicBoolean(false); Arrays.stream(array).forEach(row -> { if (Arrays.binarySearch(row,target) >= 0){ result.set(true); } }); return result.get(); }  }
SearchInDoubleDimArray { public static boolean findByBinarySearch(int target, int [][] array) { if (array.length <= 0){ return false; } if (array[0].length <= 0){ return false; } int rowSize = array.length; int rankSize = array[0].length; if (target < array[0][0] || target > array[rowSize-1][rankSize-1]){ return false; } AtomicBoolean result = new AtomicBoolean(false); Arrays.stream(array).forEach(row -> { if (Arrays.binarySearch(row,target) >= 0){ result.set(true); } }); return result.get(); }  static boolean findByBinarySearch(int target, int [][] array); static boolean convertListQuery(int target, int [][] array); static void main(String[] args); }
SearchInDoubleDimArray { public static boolean findByBinarySearch(int target, int [][] array) { if (array.length <= 0){ return false; } if (array[0].length <= 0){ return false; } int rowSize = array.length; int rankSize = array[0].length; if (target < array[0][0] || target > array[rowSize-1][rankSize-1]){ return false; } AtomicBoolean result = new AtomicBoolean(false); Arrays.stream(array).forEach(row -> { if (Arrays.binarySearch(row,target) >= 0){ result.set(true); } }); return result.get(); }  static boolean findByBinarySearch(int target, int [][] array); static boolean convertListQuery(int target, int [][] array); static void main(String[] args);  }