Words with Repeated Anagrams
Problem statement
Given an array of lowercase words, return every input word whose letters can be rearranged to form at least one other word at a different input index.
Preserve the original input order and occurrences. Equal strings at different indices count as anagram partners.
Function
wordsWithRepeatedAnagrams(words: String[]) → String[]Examples
Example 1
words = ["listen","silent","cat","tac","dog"]return = ["listen","silent","cat","tac"]The first two and middle two words form repeated anagram groups.
Example 2
words = ["aa","aa","b"]return = ["aa","aa"]Equal occurrences at different indices are partners.
Constraints
0 <= words.length <= 100000.1 <= words[i].length <= 100.- Words contain lowercase English letters.