Compute Major and Minor Document Versions From Edit Events
Last updated: November 29, 2026
Quick Overview
A regulated document starts at version 0.1; each edit bumps the minor number and each approval promotes it to the next major version with minor 0. Given a sequence of 'edit' and 'approve' events, return the version history and reject invalid sequences.
Veeva Systems
November 29, 20260
0
0 solved
A regulated document starts at version 0.1; each edit bumps the minor number and each approval promotes it to the next major version with minor 0. Given a sequence of 'edit' and 'approve' events, return the version history and reject invalid sequences.
Vault-style versioning uses minor versions for drafts and major versions for steady-state approved content, which matters to quality and regulatory teams who must cite the exact approved version. This short problem checks careful specification of rules, simple state handling, and validation of illegal input.
What the Interviewer Expects
- Clarifies the rules before coding: start version, what an edit after approval produces
- Keeps major and minor as integers rather than parsing floats like 1.10
- Rejects approving a version that is already approved
- Returns the full history, not just the final version
- Mentions how this maps to the lifecycle state machine
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you support reverting to a prior major version and continuing edits from it?
- Customers want 1.10 to sort after 1.9; what breaks if versions are stored as floats or strings?
- How would you represent a document with an approved 2.0 and an in-progress 2.1 draft at the same time?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Start at 0.1. edit -> minor + 1. approve -> (major + 1).0. An edit after approval starts the next draft at major.1, which falls out naturally from minor + 1 on a .0 version. Approving a .0 version...
High-Level Design
Hold two integers. Never use floats: 1.10 as a float is 1.1, which is the classic bug in version handling. Format with '%d.%d' only when appending to history. Raise on unknown events or double appro...