Pangram Strings | Practice | GeeksforGeeks

Check if the given string S is a Panagram or not. A pangram is a sentence containing every letter in the English Alphabet.
Example 1:
Input: S = "Pack mY box witH fIve dozen 
            liquor jugs"
Output: 1
Explanation: Given string contains all 
English Alphabets. 
Example 2:
Input: S = "geeksFORgeeks"
Output: 0
Explanation: Given string does not contain 
all English Alphabets. 
Your Task:  
You don't need to read input or print anything. Your task is to complete the function isPanagram() which takes the string as inputs and returns 1 if the given string is panagram, otherwise 0.

Expected Time Complexity: O(N)
Expected Auxiliary Space: O(constant)

Constraints:
1 ≤ |S| ≤ 105
0
himpat2021 month ago
why this is giving runtime error?int isPanagram(string str){    vector<int> v(27,0);    int n =str.size();    if(n<26)    {        return 0;    }    for(int i=0;i<n;i++)    {        if(int(str[i])!=32){        char c = toupper(str[i]);        int a_val = int(c);        ++v[65-a_val];        }    }    for(int i=1;i<27;i++)    {        if(v[i]==0 )        {            return 0;        }    }    return 1;}
0
dipeshmakwane2 months ago
Easy C++  Solution
int isPanagram(string S){    // Your code goes here     int count[256]={0};    for(int i=0;i<S.length();i++){    S[i]=tolower(S[i]);       count[S[i]]++;
    }       for(int i=97;i<=122;i++){           if(count[i]==0){           return 0;           break;           }       }    return 1;}
0
prasadchaskar2 months ago
Python Solution:
def isPanagram(self, S):
		# code here
		alpha = []
        for i in range(97,123):
            alpha.append(chr(i))
        l = set()
        for i in S:
            if i.isalpha():
                l.add(i.lower())
        l1 = list(l)
        l1.sort()
        if l1 ==  alpha:
            return 1
        return 0
0
tygerx2 months ago
CPP 0.0 seconds
 
 int isPanagram(string S){   int arr[26] = {0};   for(int i =0; i<S.length();i++){       if(S[i]<65 || (S[i]>90 && S[i]<97)||S[i]>122){           continue;       }       if(S[i]>=97 && S[i]<=122){           S[i]-=32;       }       arr[S[i]-65]+=1;   }    for(int i =0; i<26;i++){    if(arr[i] == 0){        return 0;    }}    return 1;    }
+1
avinav26113 months ago
Easiest C++ Solution
 
0
praveenkumar1391524 months ago
#User function Template for python3import stringclass Solution:   def isPanagram(self, S):       k=set()       S=S.lower()       for i in S:           if i.isalpha():               k.add(i)       if len(k)==26:           return 1       else:           return 0
#{ #  Driver Code Starts#Initial Template for Python 3
if __name__ == '__main__':   T=int(input())   for i in range(T):       S = input()       ob = Solution()       answer = ob.isPanagram(S)       print(answer)
# } Driver Code Ends
+1
pketul22124 months ago
class Solution {
    int isPanagram(String S) {
        
        S = S.toLowerCase();
        
        for(char ch = 'a'; ch <= 'z'; ch++) {
            if(S.indexOf(ch) == -1)
                return 0;
        }
        
        return 1;
    }
}
+1
sanketsupekar6 months ago
Java Solution 0.2 Sec
class Solution {
    int isPanagram(String S) {
        S=S.toLowerCase();
        for(char i='a';i<='z';i++)
            if(!S.contains(Character.toString(i)))
            return 0;
        return 1;
    }
};
+1
badgujarsachin836 months ago

	int isPanagram(string S)
	{
	    // Your code goes here 
	   int arr[26]={0};
	    for(int i=0;i<S.size();i++){
	        arr[tolower(S[i])-'a']++;
	    }
	    for(int i=0;i<26;i++){
	        if(arr[i]==0){
	            return 0;
	        }
	    }
	    return 1;
	}
-1
gauravg770617 months ago
 int isPanagram(string S){    // Your code goes here     int arr[26]={0};    for(int i=0;i<S.length();i++){        if(S[i]>='a' && S[i]<='z'){            arr[S[i]-'a']++;        }        else if(isupper(S[i])){            S[i]=tolower(S[i]);            arr[S[i]-'a']++;        }    }    for(int i=0;i<26;i++){        if(arr[i]==0){            return 0;        }    }    return 1;}
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.