Array Containment with Multiplicities
Updated
Problem statement
Return whether available contains every occurrence requested by required. Each available position may be used at most once.
Order does not matter, but multiplicity does. An empty required array is always contained, including in an empty available array.
Function
containsAll(required: int[], available: int[]) → booleanExamples
Example 1
required = [2,2]available = [1,2,2,3]return = trueThe two requested copies of 2 use two different available positions.
Example 2
required = [2,2]available = [1,2,3]return = falseOnly one copy of 2 is available, so the second request cannot be matched.
Constraints
0 <= required.length, available.length <= 10000.-1000000000 <= required[i], available[i] <= 1000000000.
More Expedia Phone Screen questions
- Find the Shortest Round TripPHONE SCREEN · Seen Jul 2026
- Two SumPHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2024
- Merge Two Sorted Linked ListsPHONE SCREEN · ONSITE INTERVIEW · Seen May 2023
- Assign CookiesPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2022
- Kth Smallest Value in a BSTPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2022
- Reverse a Singly Linked ListPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2022
- Climbing StairsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2021
- First Substring OccurrencePHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2021
- Merge Sorted Arrays in PlacePHONE SCREEN · ONSITE INTERVIEW · Seen May 2019
- Subtract the Next Smaller ValuePHONE SCREEN · Seen Oct 2018
Similar questions at other companies
- Majority ElementByteDance · PHONE SCREENByteDance interview questions
- Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
- Recommend Films from Viewers Who Watched Everything You DidBloomberg LP · PHONE SCREENBloomberg LP interview questions
- Find Unique ElementsCisco · PHONE SCREENCisco interview questions
- Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
- Two SumAmazon · OA · PHONE SCREEN
- Employee Count Median, Mean and ModeClay · PHONE SCREEN
- Two SumBNSF Railway · PHONE SCREENBNSF Railway interview questions
- Single-Condition Product FilterCrowdstrike · PHONE SCREENCrowdstrike interview questions
- Cross-Day User Trust ScoresAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
Interview reports that mention this question
Expedia interview experiences
- Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
- Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
- Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
- Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
- Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)