diff --git a/2762. Continuous Subarrays b/2762. Continuous Subarrays new file mode 100644 index 0000000..7301368 --- /dev/null +++ b/2762. Continuous Subarrays @@ -0,0 +1,22 @@ +class Solution { +public: + long long continuousSubarrays(vector& nums) { + map mp; + int left,right=0; + int n=nums.size(); + long long cnt=0; + while(rightfirst-mp.begin()->first>2){ + mp[nums[left]]--; + if(mp[nums[left]]==0){ + mp.erase(nums[left]); + } + left++; + } + cnt+=right-left+1; + right++; + } + return cnt; + } +};