Given a sentence and a dictionary of roots, replace every word in the sentence that has a root as a prefix with its shortest such root. Words without a matching root stay unchanged.
Input
Output: the transformed sentence.
the cattle was rattled by the battery cat bat rat
the cat was rat by the bat
a aadsfasf absbs bbab cadsfafs a b c
a a a b c
Run your code against the sample tests, or Submit to run the full suite.