← 返回 meta 的题目列表Discuss Read-heavy vs Write-heavy for Top K Frequent Elements
类型:online_judge
Design a system to find the top K frequent elements in an array, while discussing different implementations for read-heavy and write-heavy scenarios.
Requirements:
The system should consider performance implications for different scenarios.
An array nums which consists of n integers, where 1 <= n <= 10^5.
An integer k, indicating the number of top frequent elements to return, where 1 <= k <= 10^5.
Example:
Input: nums = [1,1,1,2,2,3], k = 2
Output: [1,2]
Input: nums = [1], k = 1
Output: [1]
Example
Input
1 1 1 2 2 3
2