Easy · Binary Search

Find Smallest Letter Greater Than Target

Given a list of lowercase letters sorted in non-decreasing order and a target letter, return the smallest letter in the list that is strictly greater than the target; if there is no such letter, return the first letter of the list.

Examples

Example 1

['c','f','j'], t='a'

Output: 'c'

Example 2

['c','f','j'], t='c'

Output: 'f'

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Binary Search problems