Second maximum word P89872


Statement
 

pdf   zip

html

Write a program that prints the second largest word, in alphabetical order, of a given a sequence of words, ignoring repetitions.

For instance, if the words are “hola”, “adeu”, “hola”, “hi” and “bye”, then the asked word is “hi”, because it is not relevant that “hola” appears more than once.

Input

Input consists of several words, all made up of only lowercase letters. There will always be at least two different words.

Output

Print the second largest word in alphabetical order, ignoring repetitions.

Public test cases
  • Input

    hola
    adeu
    hola
    hi
    bye
    

    Output

    hi
    
  • Input

    z
    z
    y
    

    Output

    y
    
  • Input

    x
    yy
    zzz
    yy
    x
    

    Output

    yy
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Salvador Roura
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Java Python
    User solutions
    C C++ Java Python