Pangrams

Sort by

recency

|

391 Discussions

|

  • + 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";
    }
    
  • + 0 comments

    C# solution

    public static string pangrams(string s)
    {
        var lowerString = s.ToLower();
        char[] characters = lowerString.ToCharArray().Where(e => !string.IsNullOrEmpty(e.ToString().Trim())).ToArray();
    
        var charList = new List<char>();
        foreach(var character in characters)
        {
            if(charList.Any(e => e == character))
                continue;
    
            charList.Add(character);
        }
    
        if(charList.Count == 26)
            return "pangram";
    
        return "not pangram";
    }
    
  • + 0 comments

    My solution for typescript:

    function pangrams(s: string): string {
        const ALPHABET_LENGTH = 26;
        const IS_PANGRAM = 'pangram';
        const IS_NOT_PANGRAM = 'not pangram'
        
        const isValidChar = (char: string): boolean => char !== ' ';
        
        return new Set(s
            .split('')
            .reduce((acc, char) => {
            return isValidChar(char) ? [...acc, char.toLowerCase()] : acc;
        }, [])).size === ALPHABET_LENGTH ? IS_PANGRAM : IS_NOT_PANGRAM;  
    }
    
  • + 0 comments

    The simplest logic in python

    def createAsciModel():
        a=97
        z=122
        res = []
        while(True):
            if(a>z):
                break
            res.append(a)
            a= a+1
        return res
    
    def checkAsciModel(record, asciModel):
        for idx in range(len(asciModel)):
            asci = asciModel[idx]
            if asci == (ord(record)):
                return idx
    def checkPangram(lowerCase, createAsciModel):
        asciModel = createAsciModel
        for records in lowerCase:
            idx = checkAsciModel(records,asciModel)
            if not idx and idx != 0:
                continue
            asciModel.pop(idx)
        return asciModel
    
    def pangrams(s):
        # Write your code here
        lowerCase = s.lower()
        asciModel = createAsciModel()
        pangram = checkPangram(lowerCase, asciModel)
        if len(pangram)>0:
            return 'not pangram'
        return 'pangram'