Badminton tournaments series,hackerrank solutions,by codexritik


Badminton tournaments series

Given an array of names of winner condidates in an badminton matches series. The candidate name in array represents a number of matches won in the event. Print the name of candidates who won the max matches . If there is tie, print lexicographically smaller name
Input :ravi,shalini,kamal,joya,ravi,lalit,ravi,shalini,karati,shalini
Output : ravi
We have six Candidates with name 
'ravi','shalini', 'kamal', 'joya','lalit','karati' 
The candidates ravi and shalini maximum winner. 
Since ravi is alphabetically smaller, we print ravi.
Input Format
comma seprated candidates name
Constraints
len(name)>0
Output Format
single string winner condidate name
Sample Input 0
ravi,kamal,joya,lalit,joya,shalini,karati,joya,kamal
Sample Output 0
joya
solution;
a=input()
a=a.split(",")
b=""
c=0
d=0
for x in a:
    for y in a:
        if(y==x):
                c=c+1
    if(c>d):
        b=x
        d=c
    c=0    
print(b)
    
Badminton tournaments series,hackerrank solutions,by codexritik Badminton tournaments series,hackerrank solutions,by codexritik Reviewed by CodexRitik on February 08, 2020 Rating: 5

No comments:

Powered by Blogger.