讨论/《画解剑指 Offer》 - 剑指 Offer 53 - II. 0~n-1 中缺失的数字/
《画解剑指 Offer》 - 剑指 Offer 53 - II. 0~n-1 中缺失的数字
共 1 个回复
public int missingNumber(int[] nums) {//0~n-1 中缺失的数字
        int left =0;
        int right = nums.length-1;
        while(left<=right){
            int mid = (left+right)/2;
            if(nums[mid] == mid){
                left =mid+1;
            }else {
                right =mid-1;
            }
        }
        return left;