Tap here to switch tabs
Problem
Submissions

Problem: Top K Frequent Words

med
30 min
Explore how to find the top k most frequent words in a given list by using trie data structures. Understand sorting by frequency and lexicographical order, and practice implementing solutions efficiently.

Statement

Given a list of strings words and an integer k, return the k most frequently occurring strings.

Note: The result should be sorted in descending order based on frequency. If multiple words have the same frequency, they should be sorted in lexicographical order.

Constraints:

  • 1≤1 \leq words.length ≤100\leq 100

  • 1≤1 \leq words[i].length ≤10\leq 10

  • 1≤1 \leqk ≤\leq number of unique words in the list

  • words[i] consists of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Top K Frequent Words

med
30 min
Explore how to find the top k most frequent words in a given list by using trie data structures. Understand sorting by frequency and lexicographical order, and practice implementing solutions efficiently.

Statement

Given a list of strings words and an integer k, return the k most frequently occurring strings.

Note: The result should be sorted in descending order based on frequency. If multiple words have the same frequency, they should be sorted in lexicographical order.

Constraints:

  • 1≤1 \leq words.length ≤100\leq 100

  • 1≤1 \leq words[i].length ≤10\leq 10

  • 1≤1 \leqk ≤\leq number of unique words in the list

  • words[i] consists of lowercase English letters.