← Figma Interview Insights

Figma·Software Engineer·Technical Phone Screen·Senior

Senior
Apr 2026

Summary

Figma coding screen for a software engineer role. The problem was about extending a document layer object with batch and undo functionality, and the memory-efficiency constraint is what made it actually interesting.

Questions Asked (1)

Q1

You're given a Document Layer object with apply(key, value) and get(key) methods. Implement batch() to mark the start of a tracked batch, and undo() to revert all changes made since the last batch() call. The constraint is memory efficiency: for each key touched in the batch, only store the original value it had before the batch started, not every intermediate change.

Algorithms & Data StructuresTechnical Trade-offsSystem Design
Author's notes

The naive approach I almost went with was just logging every single apply() call in order.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and constraints, then design a solution using a map to track original values for keys modified during the batch. Implement batch() to initialize the tracking map and undo() to restore original values and clear the map. Discuss trade-offs and edge cases to demonstrate thoroughness.

Pro tip: Mention that you would only record the original value the first time a key is modified in the batch, and consider using a sentinel value to handle keys that didn't exist before. This shows attention to memory efficiency and correctness.

1. Clarify Requirements

Ask questions to confirm the expected behavior: What happens if undo() is called without a batch? Can batches be nested? Should undo() be callable multiple times?

2. Design Data Structures

Use a map (e.g., HashMap) to store original values for keys modified during the batch. For keys that didn't exist, use a sentinel value (e.g., null or a special object) to distinguish from existing null values.

3. Implement batch() and undo()

batch() initializes the tracking map. undo() iterates over the map, restores each key to its original value (or deletes it if it didn't exist), and then clears the map.

4. Integrate with apply()

Modify apply() to check if a batch is active. If so, before applying the change, record the original value of the key if it hasn't been recorded yet in the current batch.

5. Discuss Edge Cases and Trade-offs

Cover scenarios like nested batches, multiple undo() calls, and memory usage. Explain why storing only the first original value per key is memory efficient.

Key Points to Mention

  • Memory efficiency: only store the original value per key, not intermediate changes.
  • Use of a sentinel value to represent keys that did not exist before the batch.
  • Handling of nested batches (if required) and how to manage multiple levels of undo.
  • Time complexity: O(1) for apply() and batch(), O(k) for undo() where k is the number of modified keys.
  • Edge cases: undo() without batch, multiple undo() calls, and keys with null values.
  • Integration with existing apply() and get() methods without breaking their behavior.

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