/**
* 二分查找
*
* @param arr
* @param num
* @return
*/
public static int binarySearch(int[] arr, int num) {
int low = 0;
int high = arr.length - 1;
while (low <= high) {
int mid = (high + low) / 2;
if (arr[mid] < num) {
low = mid + 1;
} else if (arr[mid] > num) {
high = mid - 1;
} else
return mid;
}
return -1;
}