nikunjsoni

330

Sep 9th, 2021
768
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Solution {
  2. public:
  3.     int minPatches(vector<int>& nums, int n) {
  4.         long long count=0, i=0, miss=1;
  5.         while(miss <= n){
  6.             if(i<nums.size() && nums[i]<=miss){
  7.                 miss += nums[i++];
  8.             }
  9.             else{
  10.                 miss += miss;
  11.                 count++;
  12.             }
  13.         }
  14.         return count;
  15.     }
  16. };
RAW Paste Data