Count Winning Electoral-State Coalitions
Problem statement
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[]) → longExamples
Example 1
electoralVotes = [3,2,1]return = 3Total votes are 6; winning subsets are {3,2}, {3,1}, and {3,2,1}.
Example 2
electoralVotes = [1,1,1]return = 4Any two states or all three states exceed half of 3.
Example 3
electoralVotes = []return = 0No coalition can win without states.
Constraints
0 <= electoralVotes.length <= 40.1 <= electoralVotes[i] <= 1000.- The answer fits a signed 64-bit integer.