Alert on Users Touching Too Many Distinct Files in a Window
Last updated: November 29, 2026
Quick Overview
Process a time-ordered stream of (timestamp, user, file) access events and emit an alert the first time a user touches more than T distinct files within any trailing window of W seconds, re-arming only after their distinct count drops back to T or below.
Concentric Ai
November 29, 20260
0
0 solved
Process a time-ordered stream of (timestamp, user, file) access events and emit an alert the first time a user touches more than T distinct files within any trailing window of W seconds, re-arming only after their distinct count drops back to T or below.
Concentric AI added user activity risk monitoring for repositories such as Windows file shares, where mass access by one account can signal ransomware or data theft. This coding round checks a streaming sliding window with distinct counting and alert suppression so analysts are not flooded.
What the Interviewer Expects
- Maintain a per-user deque of events in the window
- Track distinct files with a counter, decrementing on eviction
- Define window boundaries precisely
- Suppress repeated alerts during one burst
- Analyze memory per active user
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 replace the fixed T with a per-user baseline?
- Events arrive slightly out of order from several file servers; what changes?
- How would you shard this across machines while keeping per-user state consistent?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Events are sorted by timestamp. Window is (ts - W, ts]. Distinct files matter: reopening one file 50 times is not a burst. Alert once per burst with (user, ts, distinct_count); once the count fall...
High-Level Design
Per user keep a deque of (ts, file) and a Counter of files in the deque. On each event: append, increment, then evict from the left while the oldest timestamp is at or before ts - W, decrementing ...