Pangrams

Sort by

recency

|

394 Discussions

|

  • + 0 comments

    PHP solution

    function pangrams($s) {
        // Write your code here
      $alphabet = 'abcdefghijklmnopqrstuvwxyz';
      $result = true;
      for ($i = 0; $i < strlen($alphabet); $i++) {
        if (strpos(strtolower($s), $alphabet[$i]) === false) {
          $result = false;
          break;
        }
      }
      return $result ? 'pangram' : 'not pangram';
    }
    
  • + 0 comments

    Javascript soultion

    function pangrams(s) {
        // Write your code here
        const alphabet = 'abcdefghijklmnopqrstuvwxyz';
        const result = alphabet.split('').every(char => s.toLowerCase().includes(char));
      return result ? 'pangram' : 'not pangram';
    }
    
  • + 0 comments

    Python solution:

    def pangrams(s):
        freq = [0] * 26
        s = s.lower()
        
        for char in s:
            if char.isalpha():
                freq[ord(char) - ord("a")] += 1
                
        for i in range(len(freq)):
            if freq[i] == 0:
                return "not pangram"
                
        return "pangram"
    
  • + 0 comments
    r="".join(set(s.lower().replace(" ","")))
    if len(r)==26:
            return 'pangram'
    else:
            return 'not pangram'
    
  • + 0 comments

    C++ Solution:

    string pangrams(string s)
    {
        unordered_map<char, int> hMap;
        for(int i = 0; i < s.size(); i++)
        {
            hMap[s[i]] = 1;
        }
    
        for(int i = 0; i < 26; i++)
        {
            if(hMap['a' + i] == 0)
            {
                if(hMap['A' + i] == 0)
                {
                    return "not pangram";
                }
            }
        }
        return "pangram";
    }