Class Solution
- java.lang.Object
-
- g0701_0800.s0744_find_smallest_letter_greater_than_target.Solution
-
public class Solution extends Object
744 - Find Smallest Letter Greater Than Target.Easy
Given a characters array
lettersthat is sorted in non-decreasing order and a charactertarget, return the smallest character in the array that is larger thantarget.Note that the letters wrap around.
- For example, if
target == 'z'andletters == ['a', 'b'], the answer is'a'.
Example 1:
Input: letters = [“c”,“f”,“j”], target = “a”
Output: “c”
Example 2:
Input: letters = [“c”,“f”,“j”], target = “c”
Output: “f”
Example 3:
Input: letters = [“c”,“f”,“j”], target = “d”
Output: “f”
Constraints:
2 <= letters.length <= 104letters[i]is a lowercase English letter.lettersis sorted in non-decreasing order.letterscontains at least two different characters.targetis a lowercase English letter.
- For example, if
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description charnextGreatestLetter(char[] letters, char target)
-