Text Editor, Part 1: Basic Text Buffer
Updated
Problem 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 Phone Screen questions
- Text Editor, Part 2: Undo and RedoPHONE SCREEN · Seen Apr 2026
- 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
Similar questions at other companies
- Read Across Sound TracksAirbnb · PHONE SCREENAirbnb interview questions
- Stateful Log Transform and SearchRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
- In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
- File Storage ServiceCresta · PHONE SCREENCresta interview questions
- Return Every Matching DecryptionDuolingo · PHONE SCREENDuolingo interview questions
- Multiline Text Editor with Cursor MovementDatologyAI · PHONE SCREEN
- Reference-Counted Deduplicating File SystemCitadel · PHONE SCREENCitadel interview questions
- In-Memory Filesystem NavigationUber · PHONE SCREENUber interview questions
- Text Document HistoryNotion · PHONE SCREEN · ONSITE INTERVIEWNotion interview questions
- String Copy and Move LifecycleSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions