NewThe Learning module is now liveSee what's new

(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 wordSet of size n, where each element in wordSet is unique.
  • A list of sentences sentences of size m, 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.

Test Cases
Input
Output
Expected