← 返回 sofi 的题目列表Anagram Sentence Substitutions
类型:qbank
Given a word set containing anagrams and a list of sentence words, count all possible sentences after replacing words with their anagrams.
Requirements
Input includes wordset, a list of strings containing anagram groups.
Input also includes sentences, a list of strings representing sentence words.
A word in a sentence can be replaced by any anagram from wordset that matches it.
Return the number of possible resulting sentences.
Notes
Canonicalize each word by sorted characters or character counts, then count how many options each sentence word has.
The total number of sentences is the product of the replacement counts across words, with unchanged words contributing one option unless the prompt says otherwise.