FastPrepCheckpointed Dynamic Sequence
Problems/Checkpointed Dynamic Sequence

Checkpointed Dynamic Sequence

OpenAI logoOpenAI● HardFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an OpenAI phone screen for a full-time role. The original report gives insertion and lookup by index over a linked sequence with checkpoints taken from time to time. It leaves open the index conventions, the start, how operations are written, the validity rules, and the limits. We filled those in.

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

Keep a sequence of strings that changes as you go. It starts empty. Store it as a linked list plus checkpoints. A checkpoint is a saved reference to a node, and there is one every checkpointInterval positions.

Process operations in order. Each operation has one of these forms:

  • ["ADD", index, value]: insert value just before the element now at position index. Positions count from zero. If index equals the current size, add the value at the end. This operation gives no output.
  • ["GET", index]: return the value at position index, counting from zero.

The index and interval fields are decimal strings. All operations are valid at the moment they run. Return the GET results in the order the operations appear.

Checkpoint rule

After every insertion, checkpoint j must point at the node at position j * checkpointInterval, for every such position in the sequence. Use the checkpoints so a lookup moves along fewer than checkpointInterval links of the list.

An insertion can find the node just before its position from a checkpoint, link in the new node, and then fix the checkpoints it affects. With a doubly linked list, every old checkpoint at or after the insertion point can move back to the node before it. That way you never walk the whole rest of the list again.

Function

processCheckpointedSequence(checkpointInterval: int, operations: String[][]) → String[]

Examples

Example 1

checkpointInterval = 3operations = [["ADD","0","A"],["ADD","1","C"],["ADD","1","B"],["GET","0"],["GET","1"],["GET","2"]]return = ["A","B","C"]

The middle insertion places B before C. The three reads then return the sequence in index order.

Example 2

checkpointInterval = 2operations = [["ADD","0","red"],["ADD","0","blue"],["ADD","2","green"],["ADD","1","gold"],["GET","0"],["GET","1"],["GET","2"],["GET","3"]]return = ["blue","gold","red","green"]

The sequence gets red, then blue at the front, then green at the back, then gold in the middle. It ends as [blue, gold, red, green], and the reads return it in order. The checkpoints stay on positions 0 and 2.

Example 3

checkpointInterval = 1operations = [["ADD","0","x"],["ADD","1","z"],["ADD","1","y"],["GET","0"],["GET","1"],["GET","2"]]return = ["x","y","z"]

With interval 1, every position is a checkpoint. Inserting y before z shifts the later checkpoint references by one position: the checkpoint that pointed at z now points at y, and a new checkpoint covers z. The reads return x, y, z.

Constraints

  • 1 <= checkpointInterval <= 5000.
  • 0 <= operations.length <= 5000.
  • Each operation is exactly ["ADD", index, value] or ["GET", index].
  • For ADD, 0 <= index <= current size. For GET, 0 <= index < current size.
  • Every index is a decimal number with no leading zeros. The only exception is "0" itself.
  • Every value has length from 1 through 20 and contains printable ASCII characters.

More OpenAI Phone Screen questions

  • Secret Number Search with One-Call-Delayed FeedbackPHONE SCREEN · Seen Nov 2026
  • Determine the Winner of Three-Card HandsPHONE SCREEN · Seen Nov 2026
  • Grid Infection with Recovery After D DaysPHONE SCREEN · Seen Nov 2026
  • Sparse Plant Infection SimulationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Light Source Hits: Sample, Compare, and FitPHONE SCREEN · Seen Nov 2026
  • Rectangle Point Coverage CountsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Adaptive Calibration ErrorPHONE SCREEN · Seen Nov 2026
  • Elevator Scheduling SimulationPHONE SCREEN · Seen Nov 2026
  • Evaluate Noisy AnnotatorsPHONE SCREEN · Seen Oct 2026
  • Network Endpoint or Cycle BoundaryOA · PHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • LFU CacheFreshworks · PHONE SCREENFreshworks interview questions
  • Chatter Message WindowReddit · PHONE SCREENReddit interview questions
  • Versioned Recipe Shopping CartDecagon · PHONE SCREENDecagon interview questions
  • Ultimate Tic-Tac-Toe Move SimulatorHebbia · PHONE SCREEN
  • LFU CacheGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • Windowed Key-Value MapConfluent · PHONE SCREEN · ONSITE INTERVIEWConfluent interview questions
  • LFU CacheBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Lazy Filter over a GeneratorSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • LRU CacheServiceNow · PHONE SCREEN · ONSITE INTERVIEWServiceNow interview questions

OpenAI interview experiences

  • OpenAI OA: What It Tests (2026)
All OpenAI interview questionsSee OpenAI hiring insights
Saved
class Solution {
    public String[] processCheckpointedSequence(int checkpointInterval, String[][] operations) {
        // Write your code here.
    }
}
Checking account…