EASY TO UNDERSTAND || Simple c++ || Explanation added
Basically, I am counting the number of divisibles by using a prefix vector. Firstly, I store 1 to vector when its divisible by p otherwise storing zero there-in
**Basically, I am counting the number of divisibles by using a prefix vector. Firstly, I store 1 to vector when its divisible by p otherwise storing zero there-in. Then we find the prefix vector. We use brute force approach next and use a set of strings to check unique subarrays(to avoid getting duplicated results). Also one important thing is to separate the strings from eachother using \'.\' as [1,9] and [19] should bear a different meaning.**\n\n**C++**\n```\nclass Solution {\npublic:\n    int countDistinct(vector<int>& nums, int k, int p) {\n        int n=nums.size();\n        vector<int> v(n,0);\n        int ans=0;\n        for(int i=0;i<n;i++)\n        {\n            if(nums[i]%p==0)\n            v[i]=1;\n        }\n        for(int i=1;i<n;i++)\n        {\n            v[i]=v[i]+v[i-1];\n        }\n        set<string> s;\n        for(int i=0;i<n;i++)\n        {\n            string str=""; \n            for(int j=i;j<n;j++)\n            {\n                str+=to_string(nums[j]);\n                str+=\'.\';\n                if(i==0)\n                {\n                    if(v[j]<=k&&s.find(str)==s.end())\n                    ans++;\n                    s.insert(str);\n                }\n                else\n                {\n                    if(v[j]-v[i-1]<=k&&s.find(str)==s.end())\n                        ans++;\n                    s.insert(str);\n                }\n                \n            }\n        }\n        return ans;\n    }\n};\n```
[]