Loading...

The Top Words

A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
medium
Seniority
mid, senior

Problem

A search engine feature ranks terms by frequency to suggest autocomplete candidates. Write a function that takes a text string and an integer k, splits on whitespace, and returns the k most frequent words in descending order of frequency. Break ties alphabetically.

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a sandboxed Docker environment and grades it instantly.