TopCoder problem "NumbersGame" used in TCHS SRM 34 (Division I Level Two)



Problem Statement

    Several players play a game. Each player chooses a certain number, writes it down (in decimal notation, without leading zeroes) and sorts the digits of the notation in non-decreasing order, obtaining another number. The player who receives the largest number wins.



You are given a int[] numbers, the list of numbers inilially chosen by the players. Return the winner's resulting number.
 

Definition

    
Class:NumbersGame
Method:winningNumber
Parameters:int[]
Returns:int
Method signature:int winningNumber(int[] numbers)
(be sure your method is public)
    
 

Constraints

-numbers will contain between 2 and 50 elements, inclusive.
-Each element of numbers will be between 0 and 100000, inclusive.
-All elements of numbers will be distinct.
 

Examples

0)
    
{1,10,100,1000,10000,100000}
Returns: 1
After sorting digits all numbers become equal.
1)
    
{2345,8756}
Returns: 5678
2)
    
{9638,8210,331}
Returns: 3689

Problem url:

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

Problem stats url:

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

Writer:

Nickolas

Testers:

PabloGilberto , brett1479 , Olexiy , ivan_metelsky

Problem categories:

Sorting