Reported September 2026
Figmasimulation

Layer History with Batch Undo and Redo

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

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

Figma reported this one in September 2026, and it looks like a text editor problem in design-tool clothing. Layers, properties, batches, undo, redo. Strip the costume and it's a command history with an undo stack and a redo stack, where each stack entry is a list of property changes. If you've got an OA invite and 48 hours, this is the shape to recognize. The tricky part isn't the data structure, it's recording the right old values so undo is exact. If you blank on the live OA, StealthCoder sits invisibly on screen as a safety net and hands you the structure.

The problem

A design document contains layers. Each layer has an integer ID and a dictionary of string properties.
Process a finite sequence of history operations:
["apply", layerId, key1, value1,...] updates one or more properties on one layer. Outside an open batch, that apply is immediately committed as one undoable change.
["beginBatch"] starts a batch. Every following apply takes effect immediately but belongs to that batch.
["commitBatch"] commits the non-empty open batch as one undoable change.
["undo"] reverses the most recent committed change.
["redo"] reapplies the most recently undone change.
A new committed apply or batch clears the redo history. An undo or redo with no available history does nothing.
Return the final layers ordered by increasing layer ID. Serialize each layer as id{key=value,...}, with property keys in lexicographic order. Omit a layer when it has no properties.

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

Examples
Example 1
operations = [["apply","1","color","green"],["apply","2","shape","triangle","color","blue"],["apply","1","color","pink"],["undo"],["undo"]]
return = ["1{color=green}"]
The first undo restores layer 1 to green. The second undo removes the entire apply that created layer 2.
Example 2
operations = [["apply","1","color","green"],["beginBatch"],["apply","2","shape","triangle","color","blue"],["apply","1","color","pink"],["commitBatch"],["apply","1","color","white"],["undo"]]
return = ["1{color=pink}","2{color=blue,shape=triangle}"]
The last standalone apply is one commit, so undo restores the state produced by the earlier batch.
Example 3
operations = [["apply","7","name","button"],["beginBatch"],["apply","7","color","red"],["apply","7","color","blue","text","Save"],["commitBatch"],["undo"],["redo"]]
return = ["7{color=blue,name=button,text=Save}"]
Redo reapplies the whole batch, including the last value written to color.

Constraints
1 <= operations.length <= 200000.
At most 200000 property assignments appear across all apply operations.
Layer IDs are positive 32-bit integers written in canonical decimal form.
Keys and values are non-empty strings without {, }, =,, or :.
Batches do not nest, every commitBatch closes a non-empty open batch, and the sequence ends with no open batch.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick: store each committed change as a list of (layerId, key, oldValue, newValue) records, where oldValue can be absent. Apply mutates state immediately and appends records to the current change, or to the open batch. Undo pops a change and walks its records in reverse, restoring old values or deleting the key. Redo walks them forward, setting new values. The classic pitfall is a batch that writes the same key twice, like color in Example 3. Reverse-order undo handles it correctly, and forward redo ends on the last value. Another pitfall is forgetting to clear the redo stack on a new commit, and forgetting to drop empty layers at output. Sort layer IDs numerically, not as strings, and sort keys lexicographically. Everything is linear in total assignments. StealthCoder is the hedge if the reverse-walk detail slips under time pressure.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Layer History with Batch Undo and Redo 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. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Figma reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Layer History with Batch Undo and Redo FAQ

What's the core trick in the Figma layer history problem?+

Record inverse operations. Each change stores (layer, key, oldValue, newValue) with old value nullable. Undo replays the records in reverse restoring old values, redo replays them forward. Two stacks, undo and redo, hold these change lists. That's the whole design.

How do I handle a batch that sets the same key twice?+

Log every assignment as its own record with the value that existed at that moment. Undo in reverse order peels them back to the original state. Redo in forward order lands on the final value. Don't dedupe or merge records inside a batch.

When does the redo stack get cleared?+

Whenever a new change is committed, either a standalone apply or a commitBatch. Applies inside an open batch don't clear it until the batch commits. Undo and redo themselves never clear it, and they do nothing on an empty stack.

What output gotchas break solutions?+

Sort layer IDs numerically, not as strings. Sort keys lexicographically within each layer. Skip layers with no properties, which happens after undoing a layer's creation. Format as id{key=value,key=value} with no spaces.

How should I prepare in 48 hours?+

Write a small undo/redo system from scratch with two stacks and inverse records. Then test the three given examples by hand, especially the batch undo and redo. Watch edge cases like undo on empty history and a key that didn't exist before. Keep complexity linear in assignments.

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

OA at Figma?
Invisible during screen share
Get it