aboutsummaryrefslogtreecommitdiff
path: root/check_pangram_sentence.rs
blob: 0f69c311c5ff17f0e14c7e7756b782b4eeceed20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
struct Solution;

impl Solution {
    pub fn check_if_pangram(sentence: String) -> bool {
        let mut bit_mask: u32 = 0;
        let mut count = 0;
        for c in sentence.chars() {
            let idx = c as usize - 'a' as usize;
            if bit_mask & (1 << idx) == 0 {
                count += 1;
            }
            bit_mask |= 1 << idx;
        }
        count == 26
    }
}

fn main() {
    let sentence = String::from("thequickbrownfoxjumpsoverthelazydog");
    print!("{}", Solution::check_if_pangram(sentence));
}