PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/LinkedIn

Implement alert queries and spike detection

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's skills in streaming data structures, time-windowed aggregation, in-memory analytics for high-throughput alert ingestion, and array-based algorithmic reasoning for next-higher-element computation.

  • medium
  • LinkedIn
  • Coding & Algorithms
  • Machine Learning Engineer

Implement alert queries and spike detection

Company: LinkedIn

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

You are building an in-memory alert analytics component. Each alert has: - `timestamp` (integer seconds since epoch) - `severity` (one of a small fixed set, e.g., `INFO/WARN/ERROR/CRITICAL`) Implement data structures / APIs to support the following: 1) **Recent alerts (rolling 15 minutes)** - `countRecent(now)` returns the number of alerts with timestamps in \((now-15*60, now]\). 2) **Severity distribution for the current hour** - `severityDist(now)` returns a map `severity -> count` for alerts whose timestamps fall within the current hour window \([hourStart(now), now]\) (or \([hourStart, hourStart+3600)\) if you prefer full-hour reporting—state your assumption). - The system may receive many alerts per second; updates and queries should be efficient. 3) **Spike detection on per-minute counts** Given an array `cnt[0..n-1]` where `cnt[i]` is the number of alerts in minute `i`, compute an array `nextHigher[0..n-1]` where: - `nextHigher[i]` is the smallest index `j > i` such that `cnt[j] > cnt[i]` - if no such `j` exists, `nextHigher[i] = -1` ### Notes - You can treat (1) and (2) as streaming/online; alerts arrive over time. - State any assumptions about out-of-order timestamps, retention limits, and memory.

Quick Answer: This question evaluates a candidate's skills in streaming data structures, time-windowed aggregation, in-memory analytics for high-throughput alert ingestion, and array-based algorithmic reasoning for next-higher-element computation.

Related Interview Questions

  • Count Trips From Vehicle Logs - LinkedIn (easy)
  • Design O(1) Randomized Multiset - LinkedIn (easy)
  • Process Mutable Matrix Sum Queries - LinkedIn (medium)
  • Design a Randomized Multiset - LinkedIn (medium)
  • Can You Place N Objects? - LinkedIn (medium)
LinkedIn logo
LinkedIn
Feb 11, 2026, 12:00 AM
Machine Learning Engineer
Onsite
Coding & Algorithms
5
0
Loading...

You are building an in-memory alert analytics component. Each alert has:

  • timestamp (integer seconds since epoch)
  • severity (one of a small fixed set, e.g., INFO/WARN/ERROR/CRITICAL )

Implement data structures / APIs to support the following:

  1. Recent alerts (rolling 15 minutes)
  • countRecent(now) returns the number of alerts with timestamps in (now−15∗60,now](now-15*60, now](now−15∗60,now] .
  1. Severity distribution for the current hour
  • severityDist(now) returns a map severity -> count for alerts whose timestamps fall within the current hour window [hourStart(now),now][hourStart(now), now][hourStart(now),now] (or [hourStart,hourStart+3600)[hourStart, hourStart+3600)[hourStart,hourStart+3600) if you prefer full-hour reporting—state your assumption).
  • The system may receive many alerts per second; updates and queries should be efficient.
  1. Spike detection on per-minute counts Given an array cnt[0..n-1] where cnt[i] is the number of alerts in minute i , compute an array nextHigher[0..n-1] where:
  • nextHigher[i] is the smallest index j > i such that cnt[j] > cnt[i]
  • if no such j exists, nextHigher[i] = -1

Notes

  • You can treat (1) and (2) as streaming/online; alerts arrive over time.
  • State any assumptions about out-of-order timestamps, retention limits, and memory.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More LinkedIn•More Machine Learning Engineer•LinkedIn Machine Learning Engineer•LinkedIn Coding & Algorithms•Machine Learning Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.