**Problem Statement:**
Given the required input arguments, write an efficient algorithm to solve the **Replace Words** problem. Implement the required logic as specified by standard definitions for this classic algorithmic challenge.
**Hint / Expected Approach:**
Trie insert roots; for each word find shortest prefix
**Edge Cases to Consider:**
- (1) No roots match
- (2) Root equals whole word
- (3) Multiple matching roots
Examples
Example 1
Input:["cat","bat","rat"], "the cattle was rattled by the battery"