Easy Peasy 🔥|0 ms | Java || C||| Python
\npublic class Solution {\n    public int minPatches(int[] nums, int n) {\n        long miss = 1;\n        int i = 0;\n        int patches = 0;\n\n        while
```\npublic class Solution {\n    public int minPatches(int[] nums, int n) {\n        long miss = 1;\n        int i = 0;\n        int patches = 0;\n\n        while (miss <= n) {\n            if (i < nums.length && nums[i] <= miss) {\n                miss += nums[i];\n                i++;\n            } else {\n                miss += miss;\n                patches++;\n            }\n        }\n\n        return patches;\n    }\n}\n\n```\n\n```\nint minPatches(int* nums, int numsSize, int n) {\n    long miss = 1;\n    int i = 0;\n    int patches = 0;\n\n    while (miss <= n) {\n        if (i < numsSize && nums[i] <= miss) {\n            miss += nums[i];\n            i++;\n        } else {\n            miss += miss;\n            patches++;\n        }\n    }\n\n    return patches;\n}\n \xA0 \xA0}\n```\n```\ndef min_patches(nums, n):\n    miss = 1\n    i = 0\n    patches = 0\n\n    while miss <= n:\n        if i < len(nums) and nums[i] <= miss:\n            miss += nums[i]\n            i += 1\n        else:\n            miss += miss\n            patches += 1\n\n    return patches\n```
['C', 'Python', 'Java']