Sort by

recency

|

1926 Discussions

|

  • + 0 comments
    public static String pangrams(String s) {
      boolean[] alphabet = new boolean[26];
    
      for (int i = 0; i < s.length(); i++) {
        if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z') {
          System.out.println(s.charAt(i) - 'a');
          alphabet[(s.charAt(i) - 'a')] = true;
        } else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z') {
          alphabet[s.charAt(i) - 'A'] = true;
        }
      }
      for (int i = 0; i < alphabet.length; i++) {
        if (!alphabet[i]) {
          return "not pangram";
        }
      }
      return "pangram";
    }
    
  • + 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;
    }
    
  • + 0 comments

    Java 8:

    public static String pangrams(String s) {
            
            Set<Character> chars = new HashSet<>();
            
            for (char c : s.toLowerCase().toCharArray()) {
                if (c >= 'a' && c <= 'z') {
                    chars.add(c);    
                }
            }
            
            return chars.size() == 26 ? "pangram" : "not pangram";
        }
    
  • + 0 comments
    def pangrams(s):
        for i in range(97,123):
            if chr(i) not in s.lower():
                return 'not pangram'
        return 'pangram'
    

    or

    def pangrams(s):
        return 'pangram' if len(set(s.lower()+' '))==27 else 'not pangram'
    

    or

    def pangrams(s):
        h='abcdefghijklmnopqrstuvwxyz'
        for i in h:
            if i not in s.lower():
                return 'not pangram'
        return 'pangram'
    
  • + 0 comments

    def pangrams(s):

        alphabet = list(map(chr, range(97, 123)))
    
        for i in alphabet:
    
                if i not in  s.lower():
    
                        return 'not pangram'
    
        return 'pangram'