Click4Ai

239.

Easy

The Top-K Sampling problem involves selecting the top K words with the highest probabilities. **Example:** Given a list of words and K=3, select the top 3 words. **Constraints:** The input will be a list of words and a K parameter.

Test Cases

Test Case 1
Input: ["hello", "world", "apple"], 2
Expected: ["hello", "world"]
Test Case 2
Input: ["dog", "cat", "mouse"], 1
Expected: ["dog"]
+ 3 hidden test cases