word of lowercase English letters. Consider all of its non-empty substrings, that is, runs of consecutive letters, and imagine them listed in dictionary (lexicographic) order.
Return the substring that ends up last in that list.word="tomato" → 'tomato'
The latest letter in the word is t, and it appears twice. Of the pieces tomato and to, tomato comes later in a dictionary.
word="cacao" → 'o'
The answer must start with o, so it is just o.
word="zzyzz" → 'zzyzz'
word consists of lowercase English lettersword="tomato"
'tomato'
Run checks the first 3 tests in your browser. Submit checks all 82 tests on the server, hidden ones included.