String Deque with Constant-Time Operations
Updated
Problem statement
Implement a deque of strings with a doubly linked list and process operations in order.
push_front valueandpush_back valueinsert a value.pop_frontandpop_backremove and return one end, or returnEMPTY.frontandbackreturn one end without removal, orEMPTY.sizereturns the decimal size.
Return one string for every pop, read, or size command. Every operation must run in O(1) time.
Function
processStringDeque(operations: String[]) → String[]Examples
Example 1
operations = ["push_back a","push_front b","front","back","size","pop_front","pop_back","pop_back"]return = ["b","a","2","b","a","EMPTY"]Values are read and removed from both ends; the final pop sees an empty deque.
Example 2
operations = ["front","push_back x","pop_back","size"]return = ["EMPTY","x","0"]An empty read is reported, then x is inserted and removed.
Constraints
1 <= operations.length <= 200000- Inserted values are nonempty strings without spaces and are never the reserved word
EMPTY. - Every operation uses one of the documented forms.
More Goldman Sachs Phone Screen questions
- Best Average Student ScorePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Design Hash MapOA · PHONE SCREEN · Seen Nov 2026
- House Robber IIIPHONE SCREEN · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · Seen Nov 2026
- Check a Complete Binary TreePHONE SCREEN · Seen Oct 2026
- Meeting RoomsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Count Staircase WaysPHONE SCREEN · Seen Oct 2026
- Is a Power of TenPHONE SCREEN · Seen Oct 2026
- Minimum Traveling Salesperson TourPHONE SCREEN · Seen Oct 2026
- Square Root with Newton IterationPHONE SCREEN · Seen Oct 2026
Similar questions at other companies
- Fixed Window Average and ModeNuro · PHONE SCREENNuro interview questions
- LRU CacheApple · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
- LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
- LRU CacheAthenahealth · PHONE SCREEN
- Rate Limiter with a Sliding Window per ClientStackAdapt · PHONE SCREENStackAdapt interview questions
- LRU CacheServiceNow · PHONE SCREEN · ONSITE INTERVIEWServiceNow interview questions
- Rolling Hit CounterDatabricks · PHONE SCREEN · ONSITE INTERVIEWDatabricks interview questions
- Balanced Session ManagerPalantir · PHONE SCREENPalantir interview questions
- Design Hit CounterCharta Health · PHONE SCREENCharta Health interview questions
- Per-Client API Rate LimiterDocker · PHONE SCREEN