Find Word-Multiset Windows
Updated
Problem statement
You are given a tokenized text textWords and a nonempty list targetWords. Return every word index at which a consecutive window contains exactly the same multiset of words as targetWords.
Order within a matching window does not matter, duplicate target words retain their multiplicity, matching is case-sensitive, and result indices must be ascending.
Function
wordWindowStarts(textWords: String[], targetWords: String[]) → int[]Examples
Example 1
textWords = ["red","blue","green","blue","red"]targetWords = ["blue","red"]return = [0,3]The first and last two-word windows each contain one red and one blue word.
Example 2
textWords = ["a","a","b","a"]targetWords = ["a","a"]return = [0]Only the first window contains two copies of a.
Constraints
1 <= targetWords.length <= textWords.length <= 100000.- Every word is a nonempty ASCII string of length at most
40.
More Amazon Phone Screen questions
- Count Connected ComponentsPHONE SCREEN · Seen Dec 2026
- LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Merge Accounts by Shared AttributePHONE SCREEN · Seen Dec 2026
- Merge IntervalsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Task SchedulerOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Merge k Sorted ListsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Search in a Rotated Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Top K Frequent ElementsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Course Schedule IIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Detect Cross-Doctor Prescription Pairs Within 30 DaysOracle · ONSITE INTERVIEWOracle interview questions
- Incident MonitorStripe · OAStripe interview questions
- Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
- Longest Substring Without Repeating CharactersAngel One · PHONE SCREEN
- Group AnagramsWorkday · PHONE SCREEN
- Longest Substring Without Repeating CharactersNykaa · PHONE SCREENNykaa interview questions
- Apply Operations to Make a String EmptyFlexport · PHONE SCREENFlexport interview questions
- Longest Substring Without Repeating CharactersIBM · PHONE SCREENIBM interview questions
- Compact Conversations by Unique ListingsSierra · PHONE SCREENSierra interview questions
- Longest Substring Without Repeating CharactersTikTok · PHONE SCREENTikTok interview questions
Amazon interview experiences
- Amazon Experienced SDE Onsite Questions: 1 Experience
- Amazon SDE Onsite Interview Questions: 9 Experiences
- Amazon SDE II and L5 FDE Interview Questions: 4 Experiences
- Amazon Full-Time OA Problems, Earlier Reports (Part 5 of 5)
- Amazon Full-Time OA Problems, Recent Reports (Part 4 of 5)
- Amazon New Grad OA Problems: Every Task We Have (Part 3 of 5)