public boolean binarySearch(int nums[], int target) {
        int begin = 0, end = nums.length - 1;
        while (begin + 1 < end) {
            int mid = begin + (end - begin) / 2;
            int val = nums[mid];
            if (val == target)
                return true;
            else if (val < target) {
                begin = mid;
            } else {
                end = mid;
            }
        }
        if (nums[begin] == target)
            return true;
        else if (nums[end] == target)
            return true;
        return false;
    }