TopCoder problem "QuoteContest" used in TCHS SRM 34 (Division I Level One)



Problem Statement

    Your company held a competition to see who could come up with the best quote. The votes are in, and you must now determine the winner.



The voting was held within two groups of voters. Each quote has two numbers of votes - one from each group. The quote with the most total votes is the winner of the competition. There will be no tie for the best quote, i.e., all quotes will receive a distinct number of total votes.



You are given a String[] quotes, each element of which represents a single quote and is formatted as "VOTES_1 VOTES_2 QUOTE" (quotes for clarity). VOTES_1 and VOTES_2 are integers representing the number of votes from the first and second groups, respectively, received by the quote. QUOTE is the text of the quote. Return the text of the best quote.



 

Definition

    
Class:QuoteContest
Method:bestQuote
Parameters:String[]
Returns:String
Method signature:String bestQuote(String[] quotes)
(be sure your method is public)
    
 

Constraints

-quotes will contain between 1 and 50 elements, inclusive.
-Each element of quotes will contain between 5 and 50 characters, inclusive.
-Each element of quotes will be formatted as "VOTES_1 VOTES_2 QUOTE" (quotes for clarity only), where VOTES_1 and VOTES_2 are integers between 1 and 99, inclusive, with no leading zeroes, and QUOTE is a non-empty sequence of lowercase letters ('a'-'z').
-All QUOTEs will be distinct.
-All sums of VOTES_1 and VOTES_2 will be distinct.
 

Examples

0)
    
{"4 1 firstquote","10 2 secondquote","1 5 thirdquote"}
Returns: "secondquote"
The first quote has 5 votes, the second has 12, and the third has 6, so the second quote is the best.
1)
    
{"13 5 nocodecanbreakme","10 6 iamthebest","13 2 trytochallengeme"}
Returns: "nocodecanbreakme"
2)
    
{"1 1 justdoit","1 2 thewinnertakeitall","1 4 aboutthechallenge"}
Returns: "aboutthechallenge"
3)
    
{"1 1 theworstquoteintheworld"}
Returns: "theworstquoteintheworld"

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=7594

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=10769&pm=7594

Writer:

Nickolas

Testers:

PabloGilberto , brett1479 , Olexiy , ivan_metelsky

Problem categories:

Simple Search, Iteration, String Parsing