Problem · Design
Text Editor, Part 1: Basic Text Buffer
Learn this problemProblem statement
Implement the text buffer for a text editor. The buffer begins empty and supports insertion, deletion, and reading the current text.
Supported operations
Each operation is a string array:
["INSERT", position, text]: inserttextimmediately before the character at the zero-basedposition. A position equal to the current text length appends the text.["DELETE", start, end]: delete the characters in the half-open range[start, end).["GET"]: append the complete current text to the output.
Interview sequence
Function
processTextBuffer(operations: String[][]) → String[]Examples
Example 1
operations = [["INSERT", "0", "hello"], ["INSERT", "5", "!"], ["GET"], ["DELETE", "1", "4"], ["GET"]]return = ["hello!", "ho!"]The first query reads hello!. Deleting indices 1 through 3 removes ell, leaving ho!.
More OpenAI problems
- Segmented Durable Key-Value StorePHONE SCREEN · Seen Jul 2026
- Durable String Key-Value StorePHONE SCREEN · Seen Jul 2026
- Prefix Matrix Products and AutogradPHONE SCREEN · Seen Jul 2026
- Streaming Entropy, Part 1: Batch EntropyPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
- Streaming Entropy, Part 2: Numerically Stable EntropyPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
- Streaming Entropy, Part 3: Block-wise EntropyPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
- Streaming Entropy, Part 4: Stable Streaming EntropyPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
- Memory AllocatorPHONE SCREEN · Seen Jul 2026