Loading...

Majority Event in Stream

A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
medium
Seniority
mid, senior

Scenario

An alerting system monitors event streams from microservices. If a single event type dominates the stream, it usually signals a cascading failure or a retry storm. The detector must run in constant extra memory because the stream can be massive.

Problem

Your pipeline receives a stream of event type strings. An event type is dominant if it appears more than half the time. Given a list of event type strings, return the dominant event type if one exists, or None otherwise. Memory matters: do not store a full frequency table.

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.