96.5% using unordered_map
\n#define ll long long int\nclass Solution {\npublic:\n    int minSubarray(vector<int>& a, int p) {\n        int i,n=a.size();\n        ll s=0;\n        for(aut
```\n#define ll long long int\nclass Solution {\npublic:\n    int minSubarray(vector<int>& a, int p) {\n        int i,n=a.size();\n        ll s=0;\n        for(auto e:a)\n            s+=e;\n        int r=s%p;\n        if(r==0)\n            return 0;\n        int mn=n;\n        unordered_map<int,int> rems;\n        s=0;\n        for(i=0;i<n;i++){\n            s+=a[i];\n            int rem=s%p;\n            if(rem==r)\n                mn=min(mn,i+1);\n            if(rems.find(rem-r)!=rems.end())\n                mn=min(mn,i-rems[rem-r]);\n            if(rems.find(rem-r+p)!=rems.end())\n                mn=min(mn,i-rems[p+rem-r]);\n            rems[rem]=i;            \n        }\n        if(mn>=n)\n            return -1;\n        return mn;\n    }\n};\n```
['C', 'C++']