simple c++ solution
\nint minSubarray(vector<int>& nums, int p) {\n       \n        int mod = 0;\n        for (int n : nums){\n            mod = (mod + n) % p;    \n        }\n    
```\nint minSubarray(vector<int>& nums, int p) {\n       \n        int mod = 0;\n        for (int n : nums){\n            mod = (mod + n) % p;    \n        }\n        \n        if (mod == 0){\n            return 0;\n        }\n        \n        unordered_map<int, int> mp;\n        mp[mod] = -1;\n        int sum  = 0;\n        int res = INT_MAX;\n        for (int i = 0; i < nums.size(); ++i){\n            sum = (sum + nums[i]) % p;\n            if (mp.find(sum) != mp.end()){\n                res = min(res, i - mp[sum]);\n            }\n            int idx = (sum + mod) % p;\n            mp[idx] = i;    \n        }\n        \n        return res == INT_MAX || res == nums.size() ? -1 : res;\n    }\n```
[]