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
Coding & Algorithms
Software Engineer
Concentric Ai
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

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
Sliding window
Deque
Streaming
Anomaly detection
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 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 Problems
Sample 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 ...


Submit Your Answer
Markdown supported

Related Questions