Intuitive Hash Map
Approach\nBrute Force Method\nCapture each number in a hash map (defaultdict)\nSort the hashmap by occurances, or the higher value and cap it with the limit\nTh
# Approach\nBrute Force Method\nCapture each number in a hash map (defaultdict)\nSort the hashmap by occurances, or the higher value and cap it with the limit\nThen do the map and push to a new array\n# Complexity\n- Time complexity: O(N\u2217K\u2217Log(K))\n\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n    def findXSum(self, nums: List[int], k: int, x: int) -> List[int]:\n        ansArray=[]\n        for i in range(len(nums)-k+1):\n            ans = defaultdict(int)\n            newNum=0\n            for j in range(i, i+k):\n                ans[nums[j]]+=1\n            ansList = sorted(ans.items(), key=lambda x:(x[1], x[0]), reverse=True)[:x]\n            for i in ansList:\n                newNum+=i[0]*i[1]\n            ansArray.append(newNum)\n        return ansArray\n```
['Python3']