← Figma Interview Insights

Figma·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Figma coding screen, one question the whole time. It was a custom data structure problem that looked straightforward but had a specific memory constraint that I almost missed entirely.

Questions Asked (1)

Q1

You're given a Document Layer object with apply(key, value) and get(key) methods. Add batch() to mark the start of a tracked batch, and undo() to revert all changes made since the last batch() call. The catch: you can only store each key's original pre-batch value once, no matter how many times it gets updated within the batch.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The memory constraint is where I almost tripped up.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the semantics: batch() marks a checkpoint, and undo() reverts all changes since that checkpoint. Use a map to store original values for keys modified after batch(), but only record a key's value the first time it's changed in the batch. On undo(), iterate through the map and restore each key to its original value, then clear the map.

Pro tip: Mention that you'd use a sentinel value (e.g., a unique object) to represent 'key did not exist before batch' so you can correctly delete keys that were newly added during the batch, rather than setting them to undefined.

1. Clarify requirements and edge cases

Ask about nested batches, undo without batch, and whether undo can be called multiple times. Confirm that only the first modification per key should be recorded.

2. Design the data structure

Use a Map (or object) to store original values for keys modified since the last batch. Include a flag or sentinel to track whether a key existed before the batch.

3. Implement batch() and apply()

batch() initializes/resets the tracking map. In apply(), before updating a key, check if it's already in the map; if not, record its current value (or sentinel if absent).

4. Implement undo()

Iterate over the tracking map: for each key, restore its original value (or delete it if sentinel). Then clear the map to allow a new batch.

5. Analyze complexity and trade-offs

Time: O(1) for apply and batch, O(k) for undo where k is number of modified keys. Space: O(k). Discuss alternative approaches like logging all operations vs. storing only first values.

Key Points to Mention

  • Only store the first modification per key to avoid overwriting the original value.
  • Use a sentinel to distinguish between a key that was absent and one that had a value.
  • Ensure undo() restores the exact state before batch(), including deletions.
  • Consider nested batches: either disallow or support with a stack of tracking maps.
  • Time and space complexity: O(1) apply, O(k) undo, O(k) space.
  • Thread safety or concurrency if relevant, but likely not required.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.