Online Election
A medium-tier problem at 52% community acceptance, tagged with Array, Hash Table, Binary Search. Reported in interviews at CARS24 and 1 others.
Online Election is a design problem that asks you to build a system tracking real-time vote counts and returning the winner at any point in time. CARS24 and Atlassian both ask this. It sits at medium difficulty with about 52% acceptance, which means half the candidates who attempt it get stuck. The trap is obvious: you can naively scan all votes every query. The win is realizing you can precompute or cache results so queries run in near-constant time. If this problem hits your live OA and you blank on the optimization, StealthCoder surfaces a working solution in seconds, invisible to the proctor.
Companies that ask "Online Election"
Online Election is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made for the engineer who has done the work but might still blank with a webcam pointed at him.
Get StealthCoderThe core trick is avoiding repeated full scans of vote tallies. You need to track vote counts per candidate (Hash Table), then answer 'who's winning' queries fast. Most candidates start with a HashMap to count votes, then do a linear scan on each query. That works but it's slow. The insight is to cache the leader as votes come in, or use Binary Search on sorted vote counts if you're answering queries over a historical log. Topics here are Array, Hash Table, and Binary Search because you're either maintaining state efficiently or searching over a sorted sequence of events. The design aspect is deciding what data structure holds the truth and what gets cached. StealthCoder handles the state management and query logic without hesitation when you're under pressure.
Pattern tags
You know the problem.
Make sure you actually pass it.
Online Election recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Online Election interview FAQ
Is Online Election still asked at Atlassian and CARS24?+
Yes, both companies report asking this problem. It's a staple system-design light interview question. The acceptance rate sitting at 52% suggests it filters out candidates who haven't thought about cache optimization or event-driven design. It's not obscure.
What's the actual trick to solving this fast?+
Don't rescan all votes on every query. Use a Hash Table to track vote counts and maintain a running leader as votes arrive. When tied, use a tiebreaker rule (usually highest ID wins). Queries then return the cached leader in O(1). If querying historical snapshots, Binary Search on a sorted list of vote counts.
Does this problem actually need Binary Search?+
Not always. Binary Search applies if you're answering queries about the state at any past timestamp and votes are logged in order. Hash Table plus caching the current leader handles the live scenario. Design choice depends on the exact prompt, so read carefully.
How does Online Election relate to Hash Table interview patterns?+
It's Hash Table with a real-time twist. Instead of answering 'does this element exist' or 'count occurrences', you're updating counts and always returning the top result. Forces you to think about maintaining aggregate state, not just lookup.
Why is the acceptance rate only 52% if it's medium difficulty?+
Candidates often submit the naive O(n) scan per query solution, which passes small tests but times out on large datasets. They forget to cache or optimize. The gap between 'working' and 'accepted' is wider here because the optimization isn't immediately obvious without system design experience.
Want the actual problem statement? View "Online Election" on LeetCode →