Sort by

recency

|

1938 Discussions

|

  • + 0 comments

    C++ Easy Solution

    string pangrams(string s) {
        unordered_set<char> res;
        for(char c : s){
            if(isalpha(c)){
                res.insert(tolower(c));
            }
        }
        return (res.size()==26)? "pangram":"not pangram";
    }
    
  • + 0 comments

    easy solution in C++ Count Unique character https://www.hackerrank.com/challenges/pangrams/submissions/code/430735849

  • + 0 comments

    My C++ solution:

    string pangrams(string s) {
        bitset<26> alpha;
        for(char c: s){
            int temp = tolower(c) - 'a';
            if(temp > 25 || temp < 0)continue;
            alpha.set(temp);
        }
        if(alpha.count() == 26)return "pangram";
        return "not pangram";
    }
    
  • + 0 comments
    fn pangrams(s: &str) -> String {
        let alphabet = "abcdefghijklmnopqrstuvwxyz";
        let tested: HashSet<char> = s
            .to_ascii_lowercase()
            .chars()
            .filter(|x| x.is_ascii_alphabetic())
            .collect();
    
        if alphabet.chars().all(|x| tested.contains(&x)) {
            return "pangram".into();
        }
        "not pangram".into()
    }
    
  • + 0 comments

    Here is my c++ solution, you can watch the explanation here : https://youtu.be/-8w6U6qPNrA

    #include <bits/stdc++.h>
    
    using namespace std;
    
    int main()
    {
        string s;
        getline(cin, s);
        vector<int> c(26, 0);
        for(int i = 0; i < s.size(); i++){
            if(s[i] != ' ')
            c[tolower(s[i]) - 'a']++;
        }
        string r = "pangram";
        for(int i = 0; i < c.size(); i++){
            if(c[i] == 0){
                r = "not " + r;
                break;
            }
        }
        cout << r ;
        return 0;
    }