simple java solution
\nclass Solution {\n    public int minPatches(int[] nums, int n) {\n        int count = 0;\n        int i = 0;\n        long reach = 0;\n        \n        while
```\nclass Solution {\n    public int minPatches(int[] nums, int n) {\n        int count = 0;\n        int i = 0;\n        long reach = 0;\n        \n        while(reach<n){\n            \n            if(i>=nums.length){\n                reach += reach + 1;\n                count++;\n            }\n            \n            else if(i<nums.length && nums[i] <= (reach+1)){\n                reach += nums[i];\n                i++;\n            }\n            else{\n                reach += reach + 1;\n                count++;\n            }\n            \n        }\n        return count;\n    }\n}\n```
[]