summaryrefslogtreecommitdiff
path: root/extra-characters-in-a-string/src/main.rs
blob: f803964cae3830bd66137dd61c2988c104761132 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
fn main() {
    let tests = vec![
        ("leetscode", vec!["leet","code","leetcode"], 1),
        ("sayhelloworld", vec!["hello","world"], 3),
    ];
    
    for test in tests {
        let result = min_extra_char(
            test.0.to_string(), 
            test.1.iter().map(|s| s.to_string()).collect()
            );
        println!("{} has {} should be {}", test.0, result, test.2);
    }
}

fn min_extra_char(s: String, dictionary: Vec<String>) -> i32 {
    for i in 0..s.len() {
        for w in dictionary {
            s.starts_with(w);
        }
    }
    1
}