Convert each subarray to string and keep that as hash. It will be unique always
\nclass Solution {\npublic:\n    int countDistinct(vector<int>& nums, int k, int p) {\n        int n = nums.size();\n        unordered_set<string> mp;\n        
```\nclass Solution {\npublic:\n    int countDistinct(vector<int>& nums, int k, int p) {\n        int n = nums.size();\n        unordered_set<string> mp;\n        int ans = 0;\n        for(int i=0;i<n;i++) {\n            string hash;\n            hash+=to_string(nums[i])+",";\n            int count = 0;\n            for(int j=i;j<n;j++){\n                hash+=to_string(nums[j])+",";\n                if(nums[j] % p == 0)\n                    count++;\n                if(count>k) break;\n                if(mp.count(hash)==false)\n                {\n                    mp.insert(hash);\n                    ans++;\n                }\n            }\n            \n        }\n        return ans;\n    }\n};\n```
[]