Fair Electoral Vote Apportionment
Updated
Problem statement
Given nonnegative state populations and a nonnegative total number of votes, allocate every vote proportionally using the Hamilton largest-remainder method.
Function
allocateVotes(populations: int[], totalVotes: int) → int[]Examples
Example 1
populations = [100,200,300]totalVotes = 10return = [2,3,5]The largest remainder gives the final vote to state zero.
Example 2
populations = [1,1,1]totalVotes = 2return = [1,1,0]Equal remainders are resolved by smaller index.
Constraints
1 <= populations.length <= 10000- The population sum is positive.
- Products fit in signed 64-bit integers.
More Bloomberg LP Phone Screen questions
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Apartment Housemate PreferencesGoogle · PHONE SCREENGoogle interview questions
- Minimum Fuel Car AlignmentFivetran · PHONE SCREENFivetran interview questions
- Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
- Return Exact Cash Register ChangeBank of America · OA
- Round Prices to Match TargetAirbnb · OAAirbnb interview questions
- Delete and Freeze GameRubrik · OARubrik interview questions
- Maximum Three-Server Difficulty ScoreVisa · OAVisa interview questions
- Max Transfer RateAmazon · OA
- Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
- Adaptive Calibration ErrorOpenAI · PHONE SCREENOpenAI interview questions
Bloomberg LP interview experiences
- Bloomberg SWE Phone Screen and Onsite: 1 Experience
- Bloomberg SWE Phone Screens with Two Teams: 1 Experience
- Bloomberg AI Interview, Hiring Level Not Reported: 2 Experiences
- Bloomberg Experienced SWE AI Coding Interviews: 2 Experiences
- Bloomberg New Grad AI-Assisted Coding Rounds: 3 Experiences
- Bloomberg New Grad SWE AI-Assisted Coding Rounds: 1 Experience