Pangram Checking (GFG)
Given a string check if it is Pangram or not. A pangram is a sentence containing every letter in the English Alphabet.
Example 1:
Input: S = Bawds jog, flick quartz, vex nymph Output: 1 Explantion: In the given input, there are all the letters of the English alphabet. Hence, the output is 1.
Example 2:
Input: S = sdfs Output: 0 Explantion: In the given input, there aren't all the letters present in the English alphabet. Hence, the output is 0.
Your Task:
You need to complete the function checkPangram() that takes a string as a parameter and returns true if the string is a pangram, else it returns false.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(Number of distinct characters).
Constraints:
1 <= |S| <= 104
SOLUTION:
#User function Template for python3
''' Your task is to check if the given string is
a panagram or not.
Function Arguments: s (given string)
Return Type: boolean
'''
def checkPangram(s):
#code here
l=len(s)
if l<26:
return 0
else:
k=set(s)
if len(k)>=26:
return 1
else:
return 0
Comments
Post a Comment