744. Find Smallest Letter Greater Than Target Easy
1/**
2 * [744] Find Smallest Letter Greater Than Target
3 *
4 * Given a characters array letters that is sorted in non-decreasing order and a character target, return the smallest character in the array that is larger than target.
5 * Note that the letters wrap around.
6 *
7 * For example, if target == 'z' and letters == ['a', 'b'], the answer is 'a'.
8 *
9 *
10 * Example 1:
11 *
12 * Input: letters = ["c","f","j"], target = "a"
13 * Output: "c"
14 *
15 * Example 2:
16 *
17 * Input: letters = ["c","f","j"], target = "c"
18 * Output: "f"
19 *
20 * Example 3:
21 *
22 * Input: letters = ["c","f","j"], target = "d"
23 * Output: "f"
24 *
25 *
26 * Constraints:
27 *
28 * 2 <= letters.length <= 10^4
29 * letters[i] is a lowercase English letter.
30 * letters is sorted in non-decreasing order.
31 * letters contains at least two different characters.
32 * target is a lowercase English letter.
33 *
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/find-smallest-letter-greater-than-target/
38// discuss: https://leetcode.com/problems/find-smallest-letter-greater-than-target/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43 pub fn next_greatest_letter(letters: Vec<char>, target: char) -> char {
44 '0'
45 }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn test_744() {
56 }
57}
58
Back
© 2025 bowen.ge All Rights Reserved.