C++ Easy Solution (Important Question for Interview)
C++ Code:\n\n\n int minSubarray(vector<int>& nums, int p) {\n        int ans = nums.size();\n        int remove_sum = 0;\n        for(int i=0;i<nums.size();i++)
**C++ Code:**\n\n```\n int minSubarray(vector<int>& nums, int p) {\n        int ans = nums.size();\n        int remove_sum = 0;\n        for(int i=0;i<nums.size();i++)\n        {\n            remove_sum = (remove_sum+nums[i])%p;\n        }\n        if(remove_sum==0) return 0;\n        unordered_map<int,int>m;\n        m[0] = -1;\n        int curr = 0;\n        for(int i=0;i<nums.size();i++)\n        {\n            curr = (curr+nums[i])%p;\n            m[curr] = i;\n // extra remainder jisko hatane pr sum divisible ho jayega p se\n// p yaha add kiye hain to handle the case when remove_sum>curr\n            int rem = (curr-remove_sum+p)%p;\n            if(m.find(rem)!=m.end())\n            {\n                ans = min(ans,i-m[rem]);\n            }   \n        }\n    return ans>=nums.size() ? -1:ans;\n    }\n```
['Array', 'C', 'Sliding Window', 'Prefix Sum']