FastPrepQueue on a Vector
Problems/Queue on a Vector

Queue on a Vector

Citadel logoCitadel● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Citadel Securities software engineer video interview, posted in May 2026. The task was to code up a queue whose storage is a vector.

The report gives only that one line and says nothing else was required. It does not list the methods, the limits or what happens on an empty queue. Here, you support push, pop, front, size and empty, and pop or front on an empty queue gives -1. We also ask for amortized O(1) time per operation. You get the calls as a list of operations instead of a class. The limits and the examples are ours.

Our version is about 75% the same as the reported question.

Implement a first-in, first-out queue that keeps all of its values in one vector, an array that grows when it runs out of room, and process operations on it. Do not use a built-in queue, deque or linked list.

The queue starts empty. Each operation is a pair of integers:

  • [0, value]: push value to the back of the queue. Nothing is recorded.
  • [1, 0]: pop the front value and record it, or record -1 if the queue is empty.
  • [2, 0]: record the front value without removing it, or -1 if the queue is empty.
  • [3, 0]: record the number of values in the queue.
  • [4, 0]: record 1 if the queue is empty, otherwise 0.

Return the recorded values in operation order. Each operation should take amortized O(1) time.

Note: amortized O(1) means that any m operations take O(m) time in total, even if a single operation is sometimes slower.

Function

vectorQueue(operations: int[][]) → int[]

Examples

Example 1

operations = [[0,5],[0,8],[2,0],[1,0],[0,3],[3,0],[1,0],[1,0],[1,0],[4,0]]return = [5,5,2,8,3,-1,1]

After pushing 5 and 8, the front is 5, and the pop removes it. After pushing 3, the queue holds 8 and 3, so its size is 2. The next pops return 8 and 3. The last pop finds the queue empty and returns -1, and the empty check records 1.

Example 2

operations = [[4,0],[0,1],[0,2],[0,3],[1,0],[0,4],[0,5],[0,6],[3,0],[1,0],[2,0]]return = [1,1,5,2,3]

The queue starts empty, so the first check records 1. The pop returns 1, the first value pushed. Five values remain (2 to 6), then the pop returns 2 and the front is 3.

Constraints

  • 1 <= operations.length <= 2 * 10^5
  • operations[i].length == 2
  • 0 <= value <= 10^9
  • The first integer of each operation is between 0 and 4. For operations 1 to 4, the second integer is 0.

More Citadel Phone Screen questions

  • Speed Up a Slow FunctionOA · PHONE SCREEN · Seen Nov 2026
  • Portfolio Tickers with Constant-Time Random PickPHONE SCREEN · Seen Nov 2026
  • Square Root FunctionPHONE SCREEN · Seen Oct 2026
  • Reachable Transfer PositionsPHONE SCREEN · Seen Oct 2026
  • Spreadsheet Formula DependenciesPHONE SCREEN · Seen Oct 2026
  • Currency Arbitrage CyclePHONE SCREEN · Seen Sep 2026
  • Order Book with Cancel by Order IDPHONE SCREEN · Seen Sep 2026
  • Smart Queue of Latest PricesPHONE SCREEN · Seen Sep 2026
  • Merge Price-Delta FeedsPHONE SCREEN · Seen Sep 2026
  • Reconcile Unmatched Trades with Timestamp TolerancePHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Design Hit CounterCharta Health · PHONE SCREENCharta Health interview questions
  • Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
  • Implement a FIFO QueueByteDance · PHONE SCREENByteDance interview questions
  • Stateful Paginated Fetch NLyft · PHONE SCREENLyft interview questions
  • Music Player Operation SequenceAtlassian · PHONE SCREENAtlassian interview questions
  • Machine Message RouterOpenAI · PHONE SCREENOpenAI interview questions
  • Implement a FIFO QueueOptiver · PHONE SCREENOptiver interview questions
  • Zigzag Iterator Over Two ListsGoogle · PHONE SCREENGoogle interview questions
  • Bounded Circular QueueDatadog · PHONE SCREENDatadog interview questions
  • Moving Average of a Data StreamSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions

Citadel interview experiences

  • Citadel Securities Quant Researcher Intern Loop: 1 Experience
  • Citadel Securities Research Engineer Interview: 1 Experience
  • Citadel Securities SWE Intern First Round: 2 Experiences
  • Citadel Securities Experienced SWE Interviews: 1 Experience
  • Citadel SWE Intern Later Rounds and Superday: 13 Experiences
  • Citadel SWE Intern First-Round Questions: 20 Experiences
All Citadel interview questionsSee Citadel hiring insights
Saved
class Solution {
    public int[] vectorQueue(int[][] operations) {
      // Write your code here.
    }
}
Checking account…