FastPrepCheckpointed Dynamic Sequence

Checkpointed Dynamic Sequence

OpenAI logoOpenAI● HardFULLTIMEPHONE SCREEN

Problem statement

Maintain a dynamic sequence of strings. The sequence starts empty and is represented by a linked list plus checkpoint references spaced every checkpointInterval positions.

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

  • ["ADD", index, value]: insert value immediately before the current element at the zero-based index. When index equals the current size, append the value. This operation produces no output.
  • ["GET", index]: return the value at the zero-based index.

The index and interval fields are decimal strings. All operations are valid when they are processed. Return the GET results in operation order.

The problem statement continues
Pro

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.

FastPrep Pro
Reported in 1 OpenAI interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week
See OpenAI hiring insights
CodePython 3
Run and Submit unlock with Pro
FastPrep Pro
Reported in 1 OpenAI interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week