✅💯🔥Simple Code📌🚀|  🎓🧠Beginner friendly🔥| | using dictionary and sliding window|| sorting
IntuitionThe function computes a sliding window sum of the most frequent x elements for each window of size k.Approach1.Initialize a result list res of size len
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The function computes a sliding window sum of the most frequent x elements for each window of size k.

# Approach
<!-- Describe your approach to solving the problem. -->
1.Initialize a result list res of size len(nums) - k + 1.

2.Iterate over each valid starting index j of a k-sized subarray.

3.Create a frequency dictionary d for the subarray.

4.Sort the dictionary by frequency (descending), then by value (descending).

5.Pick the top x elements and compute their total contribution.

6.Store the computed sum in res[j].

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

Sorting the dictionary (O(k log k))

Extracting the top x elements (O(x))

Summation (O(x))

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

# Code
```python3 []
class Solution:
    def findXSum(self, nums: List[int], k: int, x: int) -> List[int]:
        res=[0]*(len(nums)-k+1)

        for j in range(len(nums)-k+1):
            sub=nums[j:j+k]
            re=0
            d={}
            for i in sub:
                if i in  d:
                    d[i]+=1
                else:
                    d[i]=1
            sorted_items = sorted(d.items(), key=lambda item: (-item[1], -item[0]))

            top_x_elements = {sorted_items[l][0] for l in range(min(x, len(sorted_items)))}

            
            for  l in top_x_elements:
                re+=(l*d[l])
            res[j]=re
        return res

        
```
['Array', 'Hash Table', 'Sliding Window', 'Python3']