Reported March 2026
Notionstack

Text Document History

Reported by candidates from Notion's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Notion OA. Under 2s to a working solution.
Founder's read

The Notion OA reported in March 2026 is a text editor with undo and redo, and the whole thing hinges on two stacks. If you've got an assessment coming in the next day or two, expect this shape: APPEND, DELETE, UNDO, REDO, GET, and a rule that new edits wipe the redo history. It's a design-flavored simulation, not a hard algorithm. The risk is getting the edge cases wrong under time pressure. StealthCoder sits invisibly on your screen during the live OA as a safety net if you blank on the state handling, but you should know the model cold before you start.

The problem

Process operations against an initially empty text document.
["APPEND", text] appends text to the end.
["DELETE", count] removes the final count characters.
["UNDO"] restores the document state before the latest applied append or delete.
["REDO"] reapplies the latest undone append or delete.
["GET"] appends the current complete text to the result.
A new append or delete after an undo clears the redo history. An undo or redo with no available history has no effect. Return the values produced by GET operations in order.

Function
runTextDocument(operations: String[][]) → String[]

Examples
Example 1
operations = [["APPEND","hello"],["APPEND","!"],["DELETE","3"],["GET"],["UNDO"],["GET"],["REDO"],["GET"],["UNDO"],["APPEND","?"],["REDO"],["GET"]]
return = ["hel","hello!","hel","hello!?"]
Undo and redo move between whole document states. Appending after the second undo clears the remaining redo state.

Constraints
1 <= operations.length <= 20000.
Each operation has exactly one of the forms listed above.
Every appended text is a non-empty printable ASCII string.
Every delete count is a positive decimal integer no larger than the current document length.
The total length of all returned strings is at most 200000.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is to stop thinking about operations and think about states. Keep an undo stack of whole document strings and a redo stack of whole document strings, plus the current text. On APPEND or DELETE, push the current text onto undo, apply the change, and clear redo. On UNDO, if undo is non-empty, push current onto redo and pop undo into current. REDO mirrors that. GET adds current to the result. The common pitfall is forgetting to clear redo on a new edit, which the example tests directly with the append after the second undo. Another is parsing the delete count, since it arrives as a string. Storing full strings is fine here because the returned output is capped at 200000 characters. If your mind goes blank mid-OA, StealthCoder can hand you this structure as a hedge, but it's about ten lines once you see it.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Text Document History cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Notion's OA.

Notion reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Text Document History FAQ

What's the trick in the Notion Text Document History problem?+

Use two stacks, one for undo and one for redo, and treat each state as a full snapshot of the text. Every APPEND or DELETE pushes the prior text to undo and clears redo. UNDO and REDO just swap the current text between the stacks.

How hard is this problem really?+

Easy to medium. There's no clever algorithm, just careful state handling. Most failures come from missed edge cases like undo with empty history or forgetting that a new edit clears redo. If you trace the sample by hand once, you'll catch most of them.

Do I need to store diffs instead of full strings?+

No. With up to 20000 operations and a limit on total returned output, storing full snapshots is acceptable for this problem. Diffs add bug risk for no real gain here. Snapshots keep UNDO and REDO trivial, so start with them.

What edge cases should I test before submitting?+

Test UNDO and REDO with empty history, which must do nothing. Test an edit after an undo to confirm redo clears. Test DELETE removing the whole document. Also remember the delete count comes in as a string, so convert it to an integer first.

How do I prepare for this in 48 hours?+

Write a small undo/redo editor from scratch with two stacks and run the sample from the problem. Then repeat it without looking. Practice similar design-style simulation questions where you maintain state across a list of commands. That covers this pattern well.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Notion.

OA at Notion?
Invisible during screen share
Get it