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 Atlassian Online Assessment questions
- 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
- Binary Search Tree IteratorOA · Seen Nov 2023
- Binary Tree Level Order TraversalOA · Seen Nov 2023
Similar questions at other companies
- Count One-Swap Number PairsCapital One · OACapital One interview questions
- How Many Sentences?Chubb · OAChubb interview questions
- Perfect SubstringsVisa · OAVisa interview questions
- Cheating CodemakerJane Street · OAJane Street interview questions
- Count Equal-Frequency SubsequencesExpedia · OAExpedia interview questions
- Count Phrases Formed by Anagram ReplacementWells Fargo · OAWells Fargo interview questions
- Ransom NoteThe Walt Disney Company · OA · PHONE SCREENThe Walt Disney Company interview questions
- Minimum Deletions to Make Every Letter Count EvenMarshall Wace · OAMarshall Wace interview questions
- Apply Operations to Make a String EmptyFlexport · PHONE SCREENFlexport interview questions
- Markov Transition Counts and ProbabilitiesRetool · ONSITE INTERVIEWRetool interview questions