Process document edit events

Quick Overview

This question evaluates implementing and manipulating a line-based document through sequential event processing, emphasizing array/list operations, string handling, and state management; it belongs to the Coding & Algorithms domain and tests data-structure and input-event processing competency.

Process document edit events

Company: Clickup

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Implement a line-based document editor. You are given: - an initial document represented as an array of strings, where each string is one line - a list of events in chronological order Each event is one of the following: 1. `{"type": "insert_line", "index": i, "text": s}`: insert a new line `s` at 0-based position `i`. Valid positions are from `0` to `document.length`. 2. `{"type": "delete_document"}`: delete the entire document so it becomes empty. Apply all events in order and return the final document as an array of strings. Be careful about corner cases such as inserting into an empty document, inserting at the beginning or end, multiple `delete_document` events in a row, and additional edits after the document has been deleted.

Overview: This question evaluates implementing and manipulating a line-based document through sequential event processing, emphasizing array/list operations, string handling, and state management; it belongs to the Coding & Algorithms domain and tests data-structure and input-event processing competency.

|Home/Coding & Algorithms/Clickup
Clickup logo
Clickup
Dec 15, 2025
mediumSoftware EngineerOnsiteCoding & Algorithms
3
0

Implement a line-based document editor.

You are given:

  • an initial document represented as an array of strings, where each string is one line
  • a list of events in chronological order

Each event is one of the following:

  1. {"type": "insert_line", "index": i, "text": s} : insert a new line s at 0-based position i . Valid positions are from 0 to document.length .
  2. {"type": "delete_document"} : delete the entire document so it becomes empty.

Apply all events in order and return the final document as an array of strings.

Be careful about corner cases such as inserting into an empty document, inserting at the beginning or end, multiple delete_document events in a row, and additional edits after the document has been deleted.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...