How Many Sentences?
Updated
Problem 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 Chubb Online Assessment questions
- Count Pairs with K Divisible Values in the IntervalOA · Seen Oct 2026
- Index of the Maximum After Left RotationsOA · Seen Oct 2026
- Maximize Revenue from Decreasing InventoryOA · Seen Oct 2026
- Minimize the Maximum Array ElementOA · Seen Oct 2026
- Minimum Distinct Prefix CostOA · Seen Oct 2026
- Flat JSON Value DifferencesOA · Seen Sep 2026
- Maximum Student-Teacher DistanceOA · Seen Sep 2026
- Minimum Cost to Reach a Target WeightOA · Seen Sep 2026
- Minimum Last-Element RelocationsOA · Seen Sep 2026
- Most Visited Sprint MarkerOA · Seen Sep 2026
Similar questions at other companies
- Count One-Swap Number PairsCapital One · OA
- Perfect SubstringsVisa · OA
- Cheating CodemakerJane Street · OA
- Count Equal-Frequency SubsequencesExpedia · OA
- How Many Sentences?Atlassian · OA
- Count Phrases Formed by Anagram ReplacementWells Fargo · OA
- Ransom NoteThe Walt Disney Company · OA · PHONE SCREEN
- Minimum Deletions to Make Every Letter Count EvenMarshall Wace · OA
- Apply Operations to Make a String EmptyFlexport · PHONE SCREEN
- Markov Transition Counts and ProbabilitiesRetool · ONSITE INTERVIEW