Java | Simple solution
\n\nUPVOTE IF YOU FIND IT USEFUL\n\n\n\nclass Solution {\n    public int minPatches(int[] nums, int n) {\n        int patches = 0, i = 0;\n        long val = 1;
<hr>\n\n***UPVOTE IF YOU FIND IT USEFUL***\n<hr>\n\n```\nclass Solution {\n    public int minPatches(int[] nums, int n) {\n        int patches = 0, i = 0;\n        long val = 1;\n        \n        while(val <= n){\n            if(i < nums.length && nums[i] <= val){\n                val += nums[i++];\n            }\n            else{\n                val += val;\n                patches++;\n            }\n            \n            //System.out.println(val);\n        }\n        \n        return patches;\n    }\n}\n```
['Array']