Problem · String
How Many Sentences?
Learn this problemProblem statement
Words are anagrams when their characters can be rearranged to match. For each sentence, replace every word independently with any anagram present in wordSet. Return the number of sentences that can be formed.
Function
countSentences(wordSet: String[], sentences: String[]) → long[]Examples
Example 1
wordSet = ["listen","silent","it","is"]sentences = ["listen it is silent"]return = [4]Each occurrence of the listen/silent anagram group has two choices, so the product is four.
Constraints
1 <= wordSet.length, sentences.length <= 1000- Inputs contain lowercase English words separated by single spaces.
- Each answer fits in a signed 64-bit integer.
More Atlassian problems
- Planning ProductionOA · Seen Feb 2025
- K-Means ClusteringOA · Seen Feb 2025
- Minimum Sorted Erasure OperationsOA · Seen Jun 2024
- Count Analogous ArraysOA · Seen Mar 2024
- Get Maximum ScoreOA · Seen Mar 2024
- Better Compression 🦀OA · Seen Mar 2024
- Romanizer 🐡OA · Seen Mar 2024
- Flower Bouquets 💐OA · Seen Mar 2024