DSA Key Problems

Replace Words

Given a dictionary of root words and a sentence, replace each word having a dictionary root as a prefix with its shortest such root, and return the transformed sentence.