id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

konstans@stuy.edu set1 > listWinRace
prev  |  next  |  chance

An array list contains the number of votes in each district for a given political candidate named Jones. There are only two candidates in the race and his opponent is named Sims. Positive numbers indicate that Jones won by that number of votes and negative numbers indicate that Sims won by that number of votes. The winner of the race is the candidate that has the most total votes from all the districts. Jones wins if there is a tie since he is the incumbent. Return true if Jones won and false if Sims won.


listWinRace([20, -15]) → true
listWinRace([20, 200, -300, 10, -10]) → false
listWinRace([-25, 20, 3, 2]) → true

...Save, Compile, Run (ctrl-enter)

public boolean listWinRace(List<Integer> votesList) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 150 Post-solution available

Copyright Nick Parlante 2017 - privacy