692. Top K Frequent Words

Practice Top K Frequent Words for free on NudgeCode: Medium, Heap pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Return the k most frequent words in words, sorted from most to least frequent. Words with the same frequency are sorted in lexicographical order.

Example

words = ["i","love","leetcode","i","love","coding"], k = 2  ->  ["i","love"]

Constraints