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
November 29, 20260
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
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
- 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 ProblemsSample 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...