re: Daily Coding Puzzles - Nov 4th - Nov 9th VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Thursday Scramblies (5 KYU): Complete the function scramble(str1, str2) that returns true if a portion of str1 characters can be rearranged to m...
 

Rust

fn scramble(str1: &str, str2: &str) -> bool {
    if str2.len() > str1.len() {
        return false;
    }
    str2.chars().all(|c| {
        str1.chars().filter(|&ch| ch == c).count() >= str2.chars().filter(|&c2| c2 == c).count()
    })
}
code of conduct - report abuse