Hashmap || Max-Heap || Priority Queue || Sliding Window-I
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
    int xsum(vector<int>& nums,unordered_map<int,int>& store, int k, int x,int index){
        priority_queue<pair<int,int>> pq;
        int ans = 0;
        for(auto it = store.begin();it!=store.end();it++){
            pq.push({it->second,it->first});
        }
        while(x-- && !pq.empty()){
            ans += pq.top().first * pq.top().second;
            pq.pop();
        }
        return ans;
    }
public:
    vector<int> findXSum(vector<int>& nums, int k, int x) {

        unordered_map<int,int> store;
        for(int i = 0;i<nums.size() && i<k;i++){
            if(!store[nums[i]]){
                store[nums[i]] = 1;
            }
            else{
                store[nums[i]]++;
            }
        }

        vector<int> answer(nums.size()-k+1,0);
        for(int i = 0;i<nums.size()-k+1;i++){
            answer[i] = xsum(nums,store,k,x,i);
            store[nums[i]]--;
            if(i+k<nums.size()){
                if(!store[nums[i+k]]){
                    store[nums[i+k]] = 1;
                }
                else{
                    store[nums[i+k]]++;
                }
            }
        }
        return answer;
    }
};
```
['Array', 'Hash Table', 'Sliding Window', 'Heap (Priority Queue)', 'C++']