← Back to problems

36. Voting Tally

EASY
CountingEasyHASH MAPLLD

Tally votes per candidate and report the leader, breaking ties in favor of whoever reached the lead first.

Count votes for candidates. Process commands from stdin, one per line. Commands: - VOTE <candidate> : record one vote for <candidate>. - COUNT <candidate> : print how many votes <candidate> has (0 if none). - WINNER : print the candidate with the most votes. If no votes have been cast, print "NONE". If two or more candidates are tied for the most votes, print "TIE <candidate>" where <candidate> is the tied candidate who received their first vote earliest. Candidate names are single tokens, case-sensitive.
Log in to submit a solution

Comments

Log into join the discussion.