Please solve the programming task below using a self-contained code snippet in a markdown code block.

Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.
 
Please complete the following python code precisely:
```python
class Solution:
    def topKFrequent(self, nums: List[int], k: int) -> List[int]:
```