import java.util.*;


public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 找缺失数字
     * @param a int整型一维数组 给定的数字串
     * @return int整型
     */
  //时间复杂度O(n),空间复杂度O(1)
    public int solve (int[] a) {
        // write code here
        int num = 0;
        for(int i=0;i<=a.length-1;i++){
            if(a[i]!=i){
                num = i;
                break;
            }
            else
                num = a.length;
        }
        return num;
    }
}

//时间复杂度O(logn),空间复杂度O(1)
 public int solve (int[] a) {
        // write code here
   int low = 0;
   int high = a.length-1;
   int mid = (low+high)/2;
   while(low<=high){
        if(a[mid]<=mid){
           low = mid+1;
           mid = (low+high)/2;
        }else{
           high = mid-1;
           mid = (low+high)/2;
        }
     }
            
    return low;
}