Sort words by frequency and alphabetically to return the top K.
Constraints
Example
>>> top_k_frequent(["i","love","leetcode","i","love","coding"], 2) ['i', 'love'] >>> top_k_frequent(["the","day","is","sunny","the","the","the","sunny","is","is"], 4) ['the', 'is', 'sunny', 'day']
Recent Submissions
No submissions yet — hit Run Tests to try!
Hints