FastPrepString Deque with Constant-Time Operations
Problems/String Deque with Constant-Time Operations

String Deque with Constant-Time Operations

Goldman Sachs logoGoldman Sachs● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Goldman Sachs technical-screen report asks for a string deque built with a doubly linked list and constant-time operations. It does not give the exact set of operations. This version uses a finite list of commands. Our version is about 86% the same as the reported question.

Implement a deque of strings with a doubly linked list and process operations in order.

  • push_front value and push_back value insert a value.
  • pop_front and pop_back remove and return one end, or return EMPTY.
  • front and back return one end without removal, or EMPTY.
  • size returns 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
All Goldman Sachs interview questionsSee Goldman Sachs hiring insights
Saved
class Solution {
    public String[] processStringDeque(String[] operations) {
      // write your code here
    }
}
Checking account…