FastPrepDocument Edit Events
Problems/Document Edit Events

Document Edit Events

ClickUp logoClickUp● EasyFULLTIMEONSITE INTERVIEW

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report names a document-edit-events exercise but omits its event schema, state transitions, output, and constraints. This practice uses an initially empty document with ordered insert and delete events and returns the final text. Approximate source match: 55%.

A document starts as the empty string. Process each event in order and return the final document.

  • ["INSERT", position, text] inserts text before the zero-based position.
  • ["DELETE", position, length] removes length characters beginning at position.

An event whose position or range is invalid for the current document is rejected and leaves the document unchanged.

Function

applyDocumentEdits(events: String[][]) → String

Examples

Example 1

events = [["INSERT","0","hello"],["INSERT","5"," world"],["DELETE","5","1"]]return = "helloworld"

The second event adds a leading space before world, and the delete removes that space.

Example 2

events = [["INSERT","0","abc"],["DELETE","4","1"],["INSERT","1","X"]]return = "aXbc"

The out-of-range delete is rejected; the final insert succeeds.

Constraints

  • 0 <= events.length <= 20000.
  • Inserted text and the final document together contain at most 200000 ASCII characters.
  • Numeric fields are nonnegative decimal integers.

Similar questions at other companies

  • Christmas Tree with N TiersVerily · ONSITE INTERVIEW
  • Bounded Word Guess SolverAtlassian · ONSITE INTERVIEWAtlassian interview questions
  • Predict Runtime Method DispatchAMD · ONSITE INTERVIEWAMD interview questions
  • Basic String Compression with Length GuardNew Relic · PHONE SCREEN · ONSITE INTERVIEW
  • Print Sentences as TableAirbnb · PHONE SCREEN · ONSITE INTERVIEWAirbnb interview questions
  • Retry with an Attempt LimitOracle · ONSITE INTERVIEWOracle interview questions
  • Extract Error Log ContextFlexTrade · ONSITE INTERVIEWFlexTrade interview questions
  • Run-Length Encode Consecutive Letter RunsMorgan Stanley · ONSITE INTERVIEWMorgan Stanley interview questions
  • String Pattern ReplacementGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • IPv4 Forward IteratorOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
See ClickUp hiring insights
Saved
class Solution {
    public String applyDocumentEdits(String[][] events) {
        // Write your code here.
    }
}
Checking account…