ProdMatch
CompaniesCitiesRolesSign in

Companies

  • Google
  • Microsoft
  • Meta
  • Amazon
  • Apple
  • Atlassian
  • Nvidia
  • Oracle
  • See all 51 →

Cities

  • Bengaluru jobs
  • Hyderabad jobs
  • Pune jobs
  • Gurugram jobs
  • Noida jobs
  • Delhi NCR jobs
  • Mumbai jobs
  • Chennai jobs
  • Remote-India jobs

Roles

  • QA / SDET Engineers
  • Backend Engineers
  • Frontend Engineers
  • Full-stack Engineers
  • Data Analysts
  • Data Engineers
  • ML / AI Engineers
  • DevOps / SRE Engineers
  • All roles →

ProdMatch

  • About
  • Career guides
  • Compare
  • Salaries
  • Skills
  • DSA practice
  • Privacy
  • Terms
  • Sign in

© 2026 ProdMatch.ai · Built for India · DPDP Act 2023 compliant · Job data sourced from official company career pages.

Back to DSA
Sliding Windowhard70 minBackend Engineer

Inventory Streaming Window Anomaly

Backend Engineer signal: sliding window + frequency map in a flash-sale inventory context. This is a ProdMatch-owned backend engineer drill, framed as a March 2026 Meesho Marketplace Infra simulation, not a copied platform question.

Company context

Meesho · Marketplace Infra

Freshness

March 2026

Product surface

flash-sale inventory

ProdMatch interview simulation based on product-team patterns; not a claim of a real company question.

Question

For flash-sale inventory, process a timestamp-ordered stream of stock updates. Find the longest contiguous window where at most k distinct risk labels appear and the total severity stays under budget.

Input

  • Array of events {label, severity} and integers k, budget.

Output

  • Maximum window length satisfying both constraints.

Constraints

  • 1 <= events.length <= 300000
  • 1 <= k <= 50
  • Severity values are positive integers.

Concepts

  • idempotency
  • queues
  • rate limiting
  • sliding window
  • frequency map
  • stream processing

labels: A,B,A,C with k=2 and budget=7 -> longest valid window length is 3

Approach

Try framing your own approach first. The 30 seconds you think before peeking is where learning happens.

Clean Solution

Reveal the approach first.

How well did you understand?

Your rating tunes when this problem shows up again.

Common Mistakes

  • Update the answer only after the window is valid.
  • Avoid recomputing the whole window on every move.

Next Similar Problems

Idempotency Streaming Window AnomalyhardLedger Streaming Window AnomalyhardCourier Streaming Window Anomalyhard