Apply Tiered SLA Retention Rules to a Snapshot Timeline

Last updated: November 29, 2026

Quick Overview

Given sorted snapshot timestamps, the current time, and SLA rules such as keep one per hour for a day and one per day for a week, return which snapshots to keep.

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

0

0

0 solved


Given sorted snapshot timestamps, the current time, and SLA rules such as keep one per hour for a day and one per day for a week, return which snapshots to keep.

Rubrik replaces backup job scripts with SLA Domains that define frequency and retention, so expiring the right snapshots is core product logic. The interviewer looks for a precise definition of buckets, correct handling of overlapping rules, and the safety rule that the newest recovery point is never expired.

What the Interviewer Expects
  • Pin down what a bucket is (aligned to epoch vs. relative to now)
  • Handle several rules that cover the same snapshot
  • Keep the earliest (or latest) snapshot per bucket consistently
  • Never delete the most recent snapshot
  • Give linear time in snapshots times rules
Key Topics to Cover
retention policy
bucketing
hash sets
SLA domains
data lifecycle
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
  • Retention is evaluated every hour. How do you make sure a snapshot kept by one run is not expired by a later run purely because buckets shifted?
  • Some snapshots are on legal hold. How does that change the code?
  • How would you do this for 50 million snapshots stored in a metadata database rather than in memory?
  • What changes if the customer's buckets must align to their local time zone with daylight saving?
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

Each rule (window, granularity) applies to snapshots younger than window. Within it, time is split into buckets of granularity, aligned to the epoch so buckets do not move as now advances. Kee...

High-Level Design

Iterate snapshots oldest first. For each rule that covers the snapshot's age, compute bucket = t // granularity. If (rule, bucket) has not been filled, fill it with this snapshot. The union of kep...


Submit Your Answer
Markdown supported

Related Questions