payal-kothari
8/10/2017 - 4:34 AM

From https://leetcode.com/problems/missing-number/description/ // binary search - O(log N)

public class Solution {
    public int missingNumber(int[] nums) {
        
        Arrays.sort(nums);
        int start = 0, end = nums.length -1;
         
        while(start <= end){
            
            int mid = (end + start) / 2;
            if (mid == nums[mid]){
                start = mid + 1;
            }else{
                end = mid - 1;
            }          
        } 
        return start ;  
    }
}