Process Deque Operations
Updated
Problem statement
Process operations on an initially empty deque. The parallel values entry is used only by a push.
push_frontandpush_back: insert the supplied value and emit nothing.pop_frontandpop_back: remove and emit the value at that end, or emit -1 when empty.frontandback: emit that end value without removing it, or -1 when empty.size: emit the current number of values.
Return all emitted integers in operation order. Values on non-push operations are ignored.
Function
runDeque(operations: String[], values: int[]) → int[]Examples
Example 1
operations = ["push_back","push_front","front","back","pop_back","size"]values = [3,2,0,0,0,0]return = [2,3,3,1]After the pushes, the deque is [2,3]. The queries emit 2 and 3, removing the back emits 3, and size then emits 1.
Example 2
operations = ["pop_front","size"]values = [0,0]return = [-1,0]An empty removal emits -1; the deque remains empty.
Constraints
0 <= operations.length, values.length <= 2000.0 <= values[i] <= 1000000000.- Both arrays have equal lengths. Every operation is push_front, push_back, pop_front, pop_back, front, back or size.
More Expedia Onsite Interview questions
- Scramble StringONSITE INTERVIEW · Seen Sep 2026
- Smallest Sufficient TeamONSITE INTERVIEW · Seen Sep 2026
- Check Anagram Pairs Index by IndexONSITE INTERVIEW · Seen Oct 2025
- Fresh Oranges Left After Rotting StopsONSITE INTERVIEW · Seen Oct 2025
- Longest Increasing SubsequenceONSITE INTERVIEW · Seen Oct 2025
- Lowest Common Ancestor with Repeated and Missing ValuesONSITE INTERVIEW · Seen Oct 2025
- Shortest Substring with Exactly K OnesONSITE INTERVIEW · Seen Oct 2025
- Middle Element of a Linked ListONSITE INTERVIEW · Seen Nov 2024
- Minimum in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Sep 2024
- Mirror Image Binary TreesONSITE INTERVIEW · Seen Sep 2024
Similar questions at other companies
- Round-Robin Iterator over IteratorsBridge · ONSITE INTERVIEWBridge interview questions
- Sliding Window Rate LimiterLotusFlare · ONSITE INTERVIEW
- Rolling CSAT TrackerDecagon · PHONE SCREEN · ONSITE INTERVIEWDecagon interview questions
- Design Hit CounterNutanix · ONSITE INTERVIEWNutanix interview questions
- Sliding-Window Rate LimiterAmazon · ONSITE INTERVIEW
- FIFO Mutex Operation TraceApple · ONSITE INTERVIEWApple interview questions
- Five-Minute Hit CounterGoogle · ONSITE INTERVIEWGoogle interview questions
- Rate Limiter with Global and Per-User LimitsOpenAI · ONSITE INTERVIEWOpenAI interview questions
- Per-Element Hit CounterUber · ONSITE INTERVIEWUber interview questions
- Metric Counter with a Fake ClockSnap Inc. · ONSITE INTERVIEWSnap Inc. 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)