Click4Ai

240.

Medium

The Top-P (Nucleus) Sampling problem involves selecting the top words with cumulative probability P. **Example:** Given a list of words and P=0.5, select the top words. **Constraints:** The input will be a list of words and a P parameter.

Test Cases

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