Loading...
Prefix Based Word Replacement
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
- Seniority
- senior
Problem
Our text normalization pipeline replaces domain-specific jargon with standardized root words. Write a function called replace_words that takes a list of root words and a sentence - for each word in the sentence, if any root is a prefix, replace with the shortest matching root. Return the modified sentence.
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.