summaryrefslogtreecommitdiff
path: root/find-smallest-letter-greater-than-target/src/main.rs
blob: aa9944c0aa2b89bd687003c0dc32baf6d33999f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
fn main() {
    println!("Hello, world!");
}

pub fn next_greatest_letter(letters: Vec<char>, target: char) -> char {
    let mut smallest: char = '~';
    let first = letters[0];

    for c in letters {
        if c > target && c < smallest {smallest = c;} 
    }
    if smallest == '~' {
        return first;
    }

    return smallest;
}