Easy to Understand 1ms Java solution
public int minPatches(int[] nums, int n) {\n        if(n<1) return 0;\n        int patch=0;//number of patches\n        int covers=0;//the cover range of curren
    public int minPatches(int[] nums, int n) {\n        if(n<1) return 0;\n        int patch=0;//number of patches\n        int covers=0;//the cover range of current array\n        for(int i=0;i<nums.length;i++){\n            if(covers>=n) return patch;\n            while(nums[i]-covers>1){\n                patch++;  //patch the covers+1\n                covers=covers*2+1;\n                if(covers>=n) return patch;\n            }\n            if(nums[i]>Integer.MAX_VALUE-covers) return patch;\n            covers=nums[i]+covers;\n        }\n        while(covers<n){\n            patch++;\n            if(covers>Integer.MAX_VALUE-covers) return patch;\n            covers=covers*2+1;\n        }\n        return patch;\n    }
[]