Implement document version history with backward and forward navigation

Quick Overview

Implement document version history with save, undo, and redo operations. Define what happens after editing an older version, preserve immutable snapshots, and explain navigation boundaries and storage costs.

Implement document version history with backward and forward navigation

Company: Patreon

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

Implement a document-history component that lets a user move backward and forward through saved document versions. The reported exercise is a document-change variant of a linear history-navigation problem. Use immutable full-document snapshots for the working version. Initialize the history with one snapshot, save new versions, move backward by a requested number of steps, and move forward by a requested number of steps. Return the current snapshot after navigation. ```hint Follow an edit after undo Decide what happens to the versions that were ahead of the current position when a new version is saved. ``` ### Constraints and Clarifications The exercise baseline uses a linear history. Moving past either end stops at that end. Saving after moving backward discards the forward branch. These history semantics are explicit assumptions to confirm for the document variant. Empty document text is valid, and navigation steps are nonnegative integers. ### Clarifying Questions - Does saving after undo discard the forward history, or should branches be retained? - Are versions complete snapshots or edit operations that must be replayed? - Should saving identical text create another version? ### What a Strong Answer Covers - A current-version representation and complete save, undo, and redo behavior - Boundary handling and branch truncation after a new save - A trace with several versions and an edit after undo - Storage and operation costs, including discarded history ### Follow-up Questions - How would storing edit deltas change navigation cost and recovery? - How would you add a history-size limit without invalidating the current position? - What changes if concurrent users must maintain separate branches?

Overview: Implement document version history with save, undo, and redo operations. Define what happens after editing an older version, preserve immutable snapshots, and explain navigation boundaries and storage costs.

Patreon logo
Patreon
Nov 30, 2026
mediumSoftware EngineerTechnical ScreenSoftware Engineering Fundamentals
0
0

Implement a document-history component that lets a user move backward and forward through saved document versions. The reported exercise is a document-change variant of a linear history-navigation problem.

Use immutable full-document snapshots for the working version. Initialize the history with one snapshot, save new versions, move backward by a requested number of steps, and move forward by a requested number of steps. Return the current snapshot after navigation.

Constraints and Clarifications

The exercise baseline uses a linear history. Moving past either end stops at that end. Saving after moving backward discards the forward branch. These history semantics are explicit assumptions to confirm for the document variant. Empty document text is valid, and navigation steps are nonnegative integers.

Clarifying Questions Guidance

  • Does saving after undo discard the forward history, or should branches be retained?
  • Are versions complete snapshots or edit operations that must be replayed?
  • Should saving identical text create another version?

What a Strong Answer Covers Guidance

  • A current-version representation and complete save, undo, and redo behavior
  • Boundary handling and branch truncation after a new save
  • A trace with several versions and an edit after undo
  • Storage and operation costs, including discarded history

Follow-up Questions Guidance

  • How would storing edit deltas change navigation cost and recovery?
  • How would you add a history-size limit without invalidating the current position?
  • What changes if concurrent users must maintain separate branches?