easy code in c++
\n# Code\n\nclass Solution {\nprivate:\n    int helper(vector<int>& nums,int k) {\n        int left=0,right=0,n=nums.size();\n        unordered_map<int,int> mpp
\n# Code\n```\nclass Solution {\nprivate:\n    int helper(vector<int>& nums,int k) {\n        int left=0,right=0,n=nums.size();\n        unordered_map<int,int> mpp;\n        int ans=0;\n        while(right<n) {\n            mpp[nums[right]]++;\n            while(mpp.size() >k && left<=right) {\n                mpp[nums[left]]--;\n                if(mpp[nums[left]] == 0) {\n                    mpp.erase(nums[left]);\n                }\n                left++;\n            }\n            ans += (right-left)+1;\n            right++;\n        }\n        return ans;\n    }\npublic:\n    int subarraysWithKDistinct(vector<int>& nums, int k) {\n        // finding the freq subarray with at most \'k\' distint element - the freq subarray with at most \'k-1\' distint element => subarray with \'k\' different integer \n        return helper(nums,k) - helper(nums,k-1);\n    }\n};\n```
['C++']