Sliding Window Approach || Brute Force  || Simple Solution with Comments
\tclass Solution {\n\tpublic:\n    //Brute Force O(n^2) time complexity \n    int countDistinct(vector& nums, int maxi, int p) {\n        int n=nums.size();\n  
\tclass Solution {\n\tpublic:\n    //Brute Force O(n^2) time complexity \n    int countDistinct(vector<int>& nums, int maxi, int p) {\n        int n=nums.size();\n        int ans=0;\n        //k represents the window size\n        \n        for(int k=1;k<=n;k++){\n            int cnt=0;\n            //cnt represent the count of values divisible by p \n            \n            set<vector<int>>s; //set of vector used to get distinct subarray\n            \n            vector<int>tt;//store the subarray\n            \n            for(int i=0;i<n;i++){\n                //Sliding window Approach\n    \n                if(i<k){\n                    tt.push_back(nums[i]);\n                    if(nums[i]%p==0){\n                        cnt++;\n                    }\n                    continue; \n                }\n                if(cnt<=maxi){     //Base condition for valid Sliding Window\n                    s.insert(tt);\n                }\n                if(tt[0]%p==0) cnt--;    //Removed from Sliding window \n                tt.erase(tt.begin());\n                \n                if(nums[i]%p==0) cnt++;   //Included in Sliding window\n                tt.push_back(nums[i]);\n            }\n            if(cnt<=maxi){             //for including last sliding window\n                    s.insert(tt);\n            }\n            \n            ans+=s.size();  //Adding up the answer\n        }\n        return ans;\n    }\n\t};
['C', 'Sliding Window']