Versioned Clause Library With Point in Time Lookups

Last updated: November 29, 2026

Quick Overview

Design a class that stores the text of standard clauses over time and supports put, delete, get as of a timestamp, and history between two timestamps.

Harvey
Coding & Algorithms
Software Engineer
Harvey
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Design a class that stores the text of standard clauses over time and supports put, delete, get as of a timestamp, and history between two timestamps.

Law firms keep precedent and clause banks, and Harvey's knowledge features need to answer what a firm's standard clause said when a deal was signed. The interviewer evaluates API design, use of sorted per-key timelines with binary search, and handling of deletes and same-timestamp writes.

What the Interviewer Expects
  • Store a sorted list of (timestamp, text) per clause
  • Use binary search for as-of reads
  • Represent deletes as tombstones rather than removing history
  • Define behavior for out-of-order and same-timestamp writes
  • Give the complexity of each operation
Key Topics to Cover
data structure design
binary search
versioning
tombstones
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you support out-of-order writes from a sync job?
  • How do you snapshot the whole library as of a time efficiently?
  • How would you persist this and survive restarts?
  • How would you diff two versions of a clause for display?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

put(id, text, ts), delete(id, ts), get(id, ts) returns the latest text at or before ts (None if deleted or not yet created), history(id, t_from, t_to) returns every version in range. Writes pe...

High-Level Design

Two parallel arrays per clause: timestamps and texts. Because timestamps are appended in order, they stay sorted, so bisect_right(ts) - 1 finds the version in effect. Deletes append a None tombsto...


Submit Your Answer
Markdown supported