Question: HackLand Election In elections that use the ballot box system for voting, each voter writes the name of a candidate on a ballot and



HackLand Election In elections that use the ballot box system for voting, each voter writes the name of a candidate on a ballot and places it in the ballot box. The candidate with the highest number of votes wins the election. If two or more candidates have the same number of votes, then the tied candidates' names are ordered alphabetically and the last name in the alphabetical order wins. For example, votes are in the names [Joe', 'Mary', 'Mary', 'Joe']. Each candidate received two votes, but Mary is alphabetically later than Joe, so she wins. Function Description Complete the function election Winner in the editor below. The function must return a string denoting the name of the winning candidate. election Winner has the following parameter(s): votes[votes[0],...votes[n-1]]: an array of strings representing the names of the candidates as voted by the voter. Constraints 1 ns 104 Input Format For Custom Testing Input from stdin will be processed as follows and passed to the function: The first line contains an integer n, the number of elements in votes. Each the n subsequent lines contains a string describing votes[i] where 0 1#!/bin/python3. 10 11 # Complete the electionWinner function below. 12 def electionWinner (votes): 13 14 if name main
Step by Step Solution
3.58 Rating (165 Votes )
There are 3 Steps involved in it
Python version 36 Python program to create and test function electionWinner def electionWinnervotes ... View full answer
Get step-by-step solutions from verified subject matter experts
