private int binarySearch(int begin, int end, int target, int[] nums) {
        while (begin <= end) {
            int mid = begin + (end - begin) / 2;
            if (nums[mid] >= target)
                end = mid - 1;
            else
                begin = mid + 1;
        }
        return begin;
    }