C++ String Hashing Set Solution | O(N^2logN) Time O(N^2) Space
\nclass Solution {\npublic:\n\n    //==================APPROACH 1 - BRUTE FORCE - Generating all substrings========================//\n    int countDistinct(vec
```\nclass Solution {\npublic:\n\n    //==================APPROACH 1 - BRUTE FORCE - Generating all substrings========================//\n    int countDistinct(vector<int>& nums, int k, int p) {\n\n        int n=nums.size();\n        set<string>s;\n\n        for(int i=0;i<n;i++)\n        {\n            string res = "";\n            int cnt=0;\n            for(int j=i;j<n;j++)\n            {\n                res += ((to_string(nums[j])+"-")); //adding "-" to handle the edge case of: 1,12 OR 11,2 in substring that would concatenate to the same string otherwise\n                if(nums[j]%p==0)\n                    ++cnt;\n                if(cnt>k)\n                    break;\n                s.insert(res);\n                    \n            }\n        }\n        return s.size();\n        \n        \n    }\n};\n```
['C']