Peak Concurrent Viewers Over Every K-Minute Window

Last updated: November 29, 2026

Quick Overview

Given per-minute concurrent viewer counts for a live stream and a window size k, return the maximum count within every contiguous window of k minutes, in order.

Meta
Coding & Algorithms
Software Engineer
Meta
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Given per-minute concurrent viewer counts for a live stream and a window size k, return the maximum count within every contiguous window of k minutes, in order.

Live video dashboards need rolling peaks, and sliding window maximum is a standard Meta onsite Hard. The interviewer is looking for a monotonic deque with a clear invariant, and an explanation of why the amortized cost is O(n) rather than O(nk).

What the Interviewer Expects
  • Starts from the O(nk) baseline and improves
  • Maintains a deque of indices with decreasing values
  • Evicts indices that fall out of the window from the front
  • Pops smaller values from the back before pushing
  • Explains the amortized O(n) bound
Key Topics to Cover
Monotonic deque
Sliding window
Amortized analysis
Queues
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
  • Compute the rolling median instead of the maximum.
  • Counts arrive as an unbounded stream; what is the memory bound?
  • Return the minimum and maximum together in one pass.
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

Array length n up to 10^5, 1 <= k <= n. Output has n - k + 1 values. Target O(n) time....

High-Level Design

Keep a deque of indices whose values are strictly decreasing from front to back. When a new value arrives, pop indices from the back while their values are at most the new value, since they can never ...


Submit Your Answer
Markdown supported