Instant Runoff Election
Updated
Problem statement
Every row in ballots ranks all candidates from most to least preferred. In each round, count each ballot for its highest-ranked remaining candidate. A candidate with strictly more than half the ballots wins.
Otherwise eliminate the candidate with the fewest votes, breaking such ties by lexicographically largest name, and repeat. If all remaining candidates tie, return the lexicographically smallest candidate.
Function
instantRunoffWinner(ballots: String[][]) → StringExamples
Example 1
ballots = [["A","B","C"],["A","C","B"],["B","C","A"],["C","B","A"]]return = "A"C is eliminated from the initial 2-1-1 round, and its ballot transfers to B; the 2-2 tie eliminates B, leaving A.
Constraints
- Every ballot contains the same distinct candidate names.
- At least one ballot and candidate exist.
More Bloomberg LP Onsite Interview questions
- Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Sustained Overspeed AlertsFleetx · ONSITE INTERVIEW
- Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
- Random Dasher Set OperationsDoorDash · ONSITE INTERVIEWDoorDash interview questions
- Propagating Fraud DetectorAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
- Deep Copy a Random-Pointer ListAmazon · ONSITE INTERVIEW
- Instant-Runoff Voting WinnerWise · ONSITE INTERVIEW
- Escape Room LeaderboardPinterest · PHONE SCREEN · ONSITE INTERVIEWPinterest interview questions
- Random Picks Excluding Recent ValuesGoogle · ONSITE INTERVIEWGoogle interview questions
- Minimum Days for Fixed-Order Tasks with CooldownCoinbase · ONSITE INTERVIEWCoinbase interview questions
- Most Frequent Call Path in Interleaved LogsRoblox · ONSITE INTERVIEWRoblox interview questions
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)