dict, sliding window

```swift []
class Solution {
    func findXSum(_ nums: [Int], _ k: Int, _ x: Int) -> [Int] {
        var ans = [Int]()
        var dict = [Int: Int]()
        
        for i in 0..<nums.count {
            dict[nums[i], default: 0] += 1
            if i < k - 1 { continue }
            
            let arr = dict.sorted{ $0.value > $1.value || $0.value == $1.value && $0.key > $1.key}
            var temp = 0
            
            for j in 0..<min(x, arr.count) {
                temp += arr[j].key * arr[j].value
            }
            
            ans.append(temp)
            
            dict[nums[i - (k - 1)], default: 0] -= 1
        
        }
        
        return ans
    }
}

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