Simple cpp solution 98.5% faster.
\nclass Solution\n{\n    public:\n        int minSubarray(vector<int> &nums, int p)\n        {\n\n            unordered_map < long long, long long > m;\n       
```\nclass Solution\n{\n    public:\n        int minSubarray(vector<int> &nums, int p)\n        {\n\n            unordered_map < long long, long long > m;\n            long long l = INT_MAX;\n            long long sum = 0;\n            m[0] = -1;\n            unsigned long long x = 0;\n            for (auto i: nums)\n                x += i;\n            x = x % p;\n            if (x == 0)\n                return 0;\n            for (int i = 0; i < nums.size(); i++)\n            {\n                sum += nums[i];\n                long long k = sum - x;\n                if (m.find(k % p) != m.end())\n                    l = min(l, i - m[k % p]);\n                m[sum % p] = i;\n            }\n            if (l == INT_MAX || l == nums.size())\n                return -1;\n            return l;\n        }\n};\n```
['Math', 'Prefix Sum']