labels is sorted alphabetically (letters may repeat, but there are at least two distinct ones). You are also given a letter after.
Return the smallest letter in labels that comes strictly after after in the alphabet. If there is none, wrap around and return the first letter of the list.
The list is already sorted; try to beat a linear scan.labels=['b', 'e', 'e', 'k', 'q'], after='e' → 'k'
"e" itself does not count, the letter must be strictly greater. The next one is "k".
labels=['d', 'h', 'm'], after='a' → 'd'
Every letter is greater than "a", and the smallest of them is "d".
labels=['c', 'c', 'w'], after='y' → 'c'
Nothing is greater than "y", so we wrap around and return the first letter, "c".
labels) ≤ 10⁴labels[i] and after are lowercase English letterslabels is sorted in non-decreasing orderlabels contains at least two distinct letterslabels=['b', 'e', 'e', 'k', 'q'], after='e'
'k'
Run checks the first 3 tests in your browser. Submit checks all 80 tests on the server, hidden ones included.