You are given an array of characters letters sorted in non-decreasing order, and a character target. There are at least letters.
Return the smallest character in letters that is lexicographically strictly greater than target. If no such character exists, return the first character in letters.
Note: The letters wrap around. If
targetis greater than or equal to all characters inletters, the answer is the first character of the array.
Constraints:
letters.length
letters[i] is a lowercase English letter.
letters is sorted in non-decreasing order.
letters contains at least
target is a lowercase English letter.
You are given an array of characters letters sorted in non-decreasing order, and a character target. There are at least letters.
Return the smallest character in letters that is lexicographically strictly greater than target. If no such character exists, return the first character in letters.
Note: The letters wrap around. If
targetis greater than or equal to all characters inletters, the answer is the first character of the array.
Constraints:
letters.length
letters[i] is a lowercase English letter.
letters is sorted in non-decreasing order.
letters contains at least
target is a lowercase English letter.