(This question is a variation of the LeetCode question 49. Group Anagrams . If you haven't completed that question yet, it is recommended to solve it first.)
You are given:
- A list of words
wordSetof sizen, where each element inwordSetis unique. - A list of sentences
sentencesof sizem, where each sentence is a string of space-separated words, and every word consists of only lowercase English letters.
Two words are considered anagrams if they contain exactly the same characters with the same frequencies, possibly in a different order. For every sentence, you are allowed to substitute any word with any of its anagrams that are present in wordSet.
Ask AI Assistant

Ask AI Assistant
Ask me anything about this coding question!
Test Cases
Input
Output
Expected