✅C++ || Explained in Hinglish || Easy
\nclass Solution {\npublic:\n    //  Approach -\n    //  Ham kya karege ki ek reach variable lenge\n    //  Reach hame bataega ki kis number tak ham pohoch sakt
```\nclass Solution {\npublic:\n    //  Approach -\n    //  Ham kya karege ki ek reach variable lenge\n    //  Reach hame bataega ki kis number tak ham pohoch sakte he jo hamare pass number he unse\n    //  Ham kya krege ki jab tak reach < n tab tak lopp chalaege\n    \n    //  Agar reach < nums[i] to matlab abhi ham nums[i] tak number generate nahi kar sakte\n    //  isliye hame kuch patch add karna hoga, or bo patch reach + 1 hoga kyuki reach tak ke number ham generate kar sakte he\n    //  Lekin Reach se Jyada nahi isliye ham reach se ek jyada number ko patch kaarege array me jisse reach increase ho jaegi\n    //  reach += reach + 1 se\n    \n    \n    // Or jab reach nums[i] se jyada ho to matlab ham nums[i] se jyada generate kar sakte nums[i] ke bina \n    // or agar nums[i] ko bhi saath le le to reach increase ho jaegi reach + nums[i] kyoki nums[i] ko ham 1 to reach sabke saath\n    // add kar sakte he to jisse max reach hamari reach + nums[i] ho jaegi\n    \n    //Ek case or jab reach nums[i] se ek kam ho tab means (nums[i] == reach + 1) is time ham reach ko nums[i] se increase kar denge\n    // kyoki ham nums[i] - 1 tak generate kar sakte agar nums[i] aa jaega to nums[i] + reach ista generate kar paege\n    \n    // For Ex - 1 5 10\n        // reach = 0         nums[i] = 1         nums[i] <= reach + 1    ye last bala case jab nums[i] == reach + 1 to reach me num[i] add karege  == > i++ (jab bhi nums[i] add ho jaega tabhi i++ karege)\n        // reach = 1         nums[i] = 5         nums[i] > reach         array me patch karege reach + 1 (1 + 1 = 2) or reach increase karege\n        // reach = 3 (1 +2)  nums[i] = 5         nums[i] > reach         array me patch karege reach + 1 (3 + 1 = 4) or reach increase karege\n        // reach = 7 (3 +4)  nums[i] = 5         nums[i] <= reach + 1    reach += nums[i]   ==> i++\n        // reach = 12(7 +5)  nums[i] = 10         nums[i] <= reach + 1    reach += nums[i]  ==> i++\n        // reach = 22 (12+10)  reach > n breack loop return the patch count (we added 2 and 4 so count will be 2)\n    \n    \n    int minPatches(vector<int>& nums, int n) {\n        long long reach = 0;             \n        int patches = 0;\n        int i = 0;\n        \n        while(reach < n)\n        {\n            if(i < nums.size() && nums[i] <= reach+1) reach += nums[i++];\n            else\n            {\n                reach += reach + 1;\n                patches++;\n            }\n        }\n        \n        return patches;\n    }\n};\n```
['Greedy', 'C']