Pangrams

  • + 0 comments

    Rust best solution

    If you’re looking for solutions to the 3-month preparation kit in either Python or Rust, you can find them below: my solutions

    pub fn pangrams(s: &str) -> String {
        //Time complexity: O(n)
        //Space complexity (ignoring input): O(1)
        let mut bit_mask = 0;
        for letter in s.to_lowercase().chars() {
            if ('a'..='z').contains(&letter) {
            let bit_pos = letter as u32 - 'a' as u32;
            bit_mask |= 1 << bit_pos;
            };
        }
        if bit_mask == (1 << 26) - 1 {
            return "pangram".to_string();
        };
    
        "not pangram".to_string()
    }