Python No Built in functions - SORT + Windows slide
IntuitionApproachi like catsComplexity
Time complexity:

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

# Approach
i like cats

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

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

# Code
```python3 []
class Solution:
    def findXSum(self, nums: List[int], k: int, x: int) -> List[int]:
        def find_sum(a, x):
            freq = {}
            for num in a:
                freq[num] = freq.get(num, 0) + 1

            top_elements = sorted(freq.items(), key=lambda item: (-item[1], -item[0]))[:x]

            return sum(item[0] * item[1] for item in top_elements)

        n = len(nums)
        res = []

        for i in range(n - k + 1):
            subarray = nums[i:i + k]
            res.append(find_sum(subarray, x))

        return res
```
['Python3']