hacker rank 36th problem solution(JAVA COMPARATOR)

36.JAVA COMPARATOR



class Checker implements Comparator<Player>{
   
    public int compare(Player a, Player b){
        if (a.score == b.score){
            return a.name.compareTo(b.name);//alphabetically
        } else {
            return b.score - a.score;//decreasing
        }
    }
}

Compiler Message
Success
Input (stdin)Download
5
amy 100
david 100
heraldo 50
aakansha 75
aleksa 150
Expected OutputDownload
aleksa 150
amy 100
david 100
aakansha 75
heraldo 50{-truncated-}
Download to view the full testcase

Comments

Popular posts from this blog

Amazon Web Services

Google Code-In mentorship experience :)

Hacker Rank all java and python problem solutions