Find the Winner Problem Statement
Given an array/list VOTES
containing names of candidates, where each entry represents the vote received by the candidate.
You need to determine the candidate with the maximum votes. In the event of a tie, return the lexicographically smaller name.
Input:
The first line contains an integer ‘T’ representing the number of test cases. Each test case consists of:
1. An integer ‘N’ indicating the total votes cast. 2. Followed by ‘N’ lines, each containing the name of a candidate who received a vote.
Output:
For each test case, output the name of the candidate who won the maximum number of votes. Print each result on a new line.
Example:
Input:
2
3
Alice
Bob
Alice
2
Charlie
Charlie
Output:
Alice
Charlie
Explanation:
In the first test case, Alice receives more votes than Bob. In the second test case, Charlie receives both votes.
Constraints:
1 ≤ T ≤ 50
1 ≤ N ≤ 10^3
1 ≤ |NAME| ≤ 20
where |NAME| represents the candidate's name length.

AnswerBot
4mo
Given an array of candidate names and their votes, find the candidate with the maximum votes, with tiebreaker based on lexicographical order.
Iterate through the array of candidate names and keep track...read more
Help your peers!
Add answer anonymously...
Expedia Group Software Developer Intern interview questions & answers
A Software Developer Intern was asked Q. Minimum Distinct Labels Problem Statement You are given N boxes on a table, each...read more
A Software Developer Intern was asked Q. Encode the Message Problem Statement Given a text message, your task is to retur...read more
A Software Developer Intern was asked Q. Incremental Partitioning Problem Statement Given two integers N and K, determine...read more
Popular interview questions of Software Developer Intern
A Software Developer Intern was asked Q1. Minimum Distinct Labels Problem Statement You are given N boxes on a table, each...read more
A Software Developer Intern was asked Q2. Encode the Message Problem Statement Given a text message, your task is to retur...read more
A Software Developer Intern was asked Q3. Incremental Partitioning Problem Statement Given two integers N and K, determine...read more
>
Expedia Group Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

