Pangrams

Sort by

recency

|

399 Discussions

|

  • + 0 comments

    hint: in typescript you can use

    let char = char.toLowerCase(); /a-z/,test(char) -> to test all alphabet (a-z and A-Z)

  • + 0 comments

    My solution in C++

    string pangrams(string s) {
        vector<bool> isTrue(26);
        
        for(char chr : s){
            chr = tolower(chr);
            if(static_cast<int>(chr)>=97 && static_cast<int>(chr)<=122 )
                isTrue[static_cast<int>(chr)-97]=true; 
         }
        bool allTrue = all_of(isTrue.begin(), isTrue.end(), [](bool n){return n;});
        if(allTrue)
            return "pangram";
        else
            return "not pangram";
    }
    
  • + 0 comments
    import string
    
    def pangrams(s):
        # Write your code here
        alphabet_set = set(string.ascii_lowercase)
        if set(s.lower()) >= alphabet_set:
            return "pangram"
        else:
            return "not pangram"
    
  • + 0 comments
    Java
    
            public static boolean checkPangram(String str) {
            // Normalize the string to lowercase and remove non-letter characters
            String normalizedStr = str.toLowerCase().replaceAll("[^a-z]", "");
    
            // Use a set to track unique letters
            HashSet<Character> lettersSet = new HashSet<>();
    
            // Add each character to the set
            for (char c : normalizedStr.toCharArray()) {
                    lettersSet.add(c);
            }
    
            // Check if the size of the set is 26 (number of letters in the alphabet)
            return lettersSet.size() == 26;
    

    }

  • + 0 comments

    Python Solution

    def pangrams(s): # Write your code here s = s.lower() letter_set = set(s) alphabet_set = set("abcdefghijklmnopqrstuvwxyz")

    if alphabet_set.issubset(letter_set):
        return "pangram"
    else:
        return "not pangram"