FastPrepCount Winning Electoral-State Coalitions
Problems/Count Winning Electoral-State Coalitions

Count Winning Electoral-State Coalitions

Google logoGoogle● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: One Google report asked how many groups of states can win an election, given each state's electoral votes. A later Google report asked the same thing as a plain subset count, and gave the array used in Example 4. Neither report gives limits or says how equal values are treated. Here, winning means strictly more than half of all votes, and states with equal votes stay separate. The limits are our choice. Our version is about 90% the same as the reported questions.

Each positive integer in electoralVotes is one state's electoral-vote count. A coalition wins when its total is strictly more than half of all votes.

Return the number of subsets of states that win. The empty subset is included in consideration but cannot win. States with equal vote counts remain distinct.

Return the exact count as a signed 64-bit integer.

Function

countWinningCoalitions(electoralVotes: int[]) → long

Examples

Example 1

electoralVotes = [3,2,1]return = 3

Total votes are 6; winning subsets are {3,2}, {3,1}, and {3,2,1}.

Example 2

electoralVotes = [1,1,1]return = 4

Any two states or all three states exceed half of 3.

Example 3

electoralVotes = []return = 0

No coalition can win without states.

Example 4

electoralVotes = [1,3,4]return = 3

The total is 8, so a winning subset needs more than 4 votes. The subsets {1,4}, {3,4} and {1,3,4} have 5, 7 and 8 votes. The subsets {4} and {1,3} have exactly 4 votes, which is not more than half, so the answer is 3.

Constraints

  • 0 <= electoralVotes.length <= 40.
  • 1 <= electoralVotes[i] <= 1000.
  • The answer fits a signed 64-bit integer.

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Coin Change IIApple · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
  • Count Strictly Increasing Subsequences of Length 3IBM · OAIBM interview questions
  • Winning Draws for a Mahjong HandZip · PHONE SCREENZip interview questions
  • Optimize Discount Selection Under a Point BudgetPalantir · OAPalantir interview questions
  • Pressure-Isolation Shutdown OrderIntuit · OAIntuit interview questions
  • Count Good SubsequencesFlexport · OAFlexport interview questions
  • Sum of Compressed Number for All SubarraysWells Fargo · OAWells Fargo interview questions
  • Count Perfect BreaksAtlassian · OAAtlassian interview questions
  • Assign Escalations to TeamsAmazon · ONSITE INTERVIEW
  • Count Subsets With a Target SumSafe Security · ONSITE INTERVIEW

Interview reports that mention this question

  • Google SWE III ML Interviews: 11 Experiences (Part 1 of 3)

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public long countWinningCoalitions(int[] electoralVotes) {
        // Write your code here.
    }
}
Checking account…