Given a string check if it is Pangram or not. A pangram is a sentence containing every letter in the English Alphabet (either lowercase or uppercase or both). For example, we say the letter A is present in the string if either 'a' is present or 'A' is present.
Example 1:
Input:
S = Bawds jog, flick quartz, vex nymph
Output: 1
Explanation: 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
Explanation: 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, or else it returns false.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(Number of distinct characters).
Constraints:
1 ≤ |S| ≤ 10^{4}

Source: geeksforgeeks | Difficulty: EASY
Tags: String algorithms

Data structures

Starter code: #User function Template for python3



class Solution:

    

    #Function to check if a string is Pangram or not.

    def checkPangram(self,s):

        #code here

Solutions:
class Solution:

	def checkPangram(self, s):
		count = 0
		org = s.lower()
		se = set(org)
		p1 = ''.join(se)
		for i in p1:
			if ord(i) in range(97, 122) or range(65, 90):
				count += 1
		if count >= 26:
			return 1
		else:
			return 0


import string

class Solution:

	def checkPangram(self, s):
		li = list(string.ascii_lowercase)
		s = s.lower()
		for i in s:
			if i in li:
				try:
					li.remove(i)
				except:
					pass
		if not li:
			return True
		return False


class Solution:

	def checkPangram(self, s):
		letters = set((c.lower() for c in s if c.isalpha()))
		return len(letters) == 26


class Solution:

	def checkPangram(self, s):
		if len(s) < 26:
			return 0
		s = s.lower()
		for ch in 'abcdefghijklmnopqrstuvwxyz':
			if ch not in s:
				return 0
		return 1


class Solution:

	def checkPangram(self, s):
		if len(s) < 26:
			return 0
		k = s.lower()
		p = ''
		d = {}
		c = 0
		for i in range(len(s)):
			if k[i] >= chr(97) and k[i] <= chr(122):
				d[k[i]] = 0
		for i in d:
			if i >= chr(97) and i <= chr(122):
				c = c + 1
		if c == 26:
			return 1
		return 0


class Solution:

	def checkPangram(self, s):
		s = s.upper()
		st = set()
		for i in range(len(s)):
			t = ord(s[i])
			if t >= 65 and t <= 90:
				st.add(s[i])
		x = len(st)
		if x == 26:
			return 1
		else:
			return 0


class Solution:

	def checkPangram(self, s):
		a = []
		if len(s) < 26:
			return False
		if len(s) >= 26:
			for i in s:
				if i.isalpha():
					if i.isupper():
						i = i.lower()
					if i not in a:
						a.append(i)
		if len(a) == 26:
			return True
		else:
			return False


class Solution:

	def checkPangram(self, s):
		chars_dict = {}
		for char in s:
			if char.isalpha():
				lower_char = char.lower()
				if chars_dict.get(lower_char):
					chars_dict[lower_char] += 1
				else:
					chars_dict[lower_char] = 1
		if len(chars_dict) == 26:
			return 1
		else:
			return 0


class Solution:

	def checkPangram(self, s):
		s = s.lower()
		st = set()
		for i in range(len(s)):
			if ord(s[i]) >= 97 and ord(s[i]) <= 122:
				st.add(s[i])
		return True if len(st) == 26 else False


class Solution:

	def checkPangram(self, s):
		a = [0] * 26
		w = list(s.lower())
		for i in w:
			if i.isalpha():
				c = ord(i) - 97
				a[c] = a[c] + 1
		if 0 in a:
			return False
		else:
			return True


class Solution:

	def checkPangram(self, s):
		count_arr = [0] * 26
		for ch in s:
			if ch.isalpha():
				count_arr[ord(ch.lower()) - ord('a')] += 1
		return all((val > 0 for val in count_arr))


import re

class Solution:

	def checkPangram(self, s):
		pattern = '[^a-zA-Z0-9\\s]'
		s2 = re.sub(pattern, '', s)
		s2 = ''.join(s2.split(' ')).lower()
		s1 = set(s2)
		if len(s1) == 26:
			return 1
		else:
			return 0


class Solution:

	def checkPangram(self, s):
		s = s.lower()
		new_string = ''
		for i in range(len(s)):
			if s[i].isalpha():
				new_string += s[i]
		new_string = list(sorted(set(new_string)))
		k = 97
		count = 0
		for i in range(len(new_string)):
			if new_string[i] == chr(k):
				count = count + 1
				k += 1
		if count == 26:
			return 1
		else:
			return 0


class Solution:

	def checkPangram(self, s):
		freq = [0] * 26
		for i in s:
			if i.isalpha():
				index = ord(i.lower()) - ord('a')
				freq[index] += 1
		for count in freq:
			if count == 0:
				return 0
		return 1


class Solution:

	def checkPangram(self, s):
		a = ''.join((i for i in s if i.isalnum()))
		b = a.lower()
		c = list(set(b))
		if len(c) != 26:
			return 0
		else:
			return 1


class Solution:

	def checkPangram(self, s):
		a = 'abcdefghijklmnoprstuvwxyz'
		s = s.lower()
		if len(s) < 26:
			return 0
		else:
			a = 'abcdefghijklmnoprstuvwxyz'
			s = s.lower()
			for i in a:
				if i not in s:
					return 0
		return 1


class Solution:

	def checkPangram(self, s):
		for i in range(97, 123):
			if s.count(chr(i)) == 0 and s.count(chr(i - 32)) == 0:
				return False
		return True


class Solution:

	def checkPangram(self, s):
		s = s.lower()
		s = list(s)
		temp = []
		count = 0
		for i in range(len(s)):
			if ord(s[i]) >= 97 and ord(s[i]) <= 122:
				if s[i] not in temp:
					count += ord(s[i])
					temp.append(s[i])
		if count == 2847:
			return 1
		else:
			return 0


class Solution:

	def checkPangram(self, s):
		if len(s) < 26:
			return 0
		else:
			char_set = set()
			for ch in s:
				if ch >= 'a' and ch <= 'z':
					char_set.add(ch)
				if ch >= 'A' and ch <= 'Z':
					ch = ch.lower()
					char_set.add(ch)
		return 1 if len(char_set) == 26 else 0


import string

class Solution:

	def checkPangram(self, s):
		alphabet = string.ascii_lowercase
		alpha_set = set(alphabet)
		s = s.replace(' ', '')
		s = s.replace(',', '')
		s = s.replace('-', '')
		s = s.lower()
		s = set(s)
		if s == alpha_set:
			return 1
		else:
			return 0


class Solution:

	def checkPangram(self, s):
		s = s.replace(' ', '')
		s = s.lower()
		if len(s) < 26:
			return 0
		else:
			l1 = []
			s = s.lower()
			for i in s:
				if i not in l1 and i != ' ' and (i != ',') and (i != '-'):
					l1.append(i)
			if len(l1) == 26:
				return 1
			else:
				return 0


class Solution:

	def checkPangram(self, s):
		s1 = s.lower()
		res = set()
		for i in range(0, len(s1)):
			val = ord(s1[i])
			if ord('a') <= val <= ord('z'):
				res.add(s1[i])
		if len(res) >= 26:
			return 1
		return 0


class Solution:

	def checkPangram(self, s):
		a = 'abcdefghijklmnopqrstuvwxyz'
		str = s.lower()
		for i in a:
			if i not in str:
				return 0
		return 1


class Solution:

	def checkPangram(self, s):
		if len(s) < 26:
			return False
		s = s.lower()
		k = 'abcdefghijklmnopqrstuvwxyz'
		for i in k:
			if i not in s:
				return False
		return True


class Solution:

	def checkPangram(self, s):
		if len(s) < 26:
			return 0
		for i in range(1, 27):
			m = chr(i + 64)
			n = chr(i + 96)
			if m in s or n in s:
				continue
			else:
				return 0
		return 1


class Solution:

	def checkPangram(self, s):
		data = set()
		for each in s:
			a = ord(each)
			if 97 <= a <= 122:
				data.add(a)
			if 65 <= a <= 90:
				data.add(a + 32)
		if len(data) == 26:
			return 1
		else:
			return 0


class Solution:

	def checkPangram(self, s):
		pangram = 'abcdefghijklmnopqrsuvwxyz'
		for char in pangram:
			if char not in s.lower():
				return False
		return True


class Solution:

	def checkPangram(self, s):
		k = 'abcdefghijklmnopqrstuvwxyz'
		s = s.lower()
		for item in k:
			if item not in s:
				return 0
		return 1


class Solution:

	def checkPangram(self, s):
		alpha = 'abcdefghijklmnoprstuvwxyz'
		s = s.lower()
		for i in alpha:
			if i not in s:
				return False
		return True


class Solution:

	def checkPangram(self, s):
		arr = [0] * 26
		for i in s:
			if ord(i) >= 65 and ord(i) <= 90:
				arr[ord(i) - 65] += 1
			elif ord(i) >= 97 and ord(i) <= 122:
				arr[ord(i) - 97] += 1
		count = 0
		for j in arr:
			if j > 0:
				count += 1
			else:
				break
		if count == 26:
			return 1
		return 0


class Solution:

	def checkPangram(self, s):
		mp = [0 for i in range(26)]
		for ch in s:
			if ord(ch) <= ord('Z') and ord(ch) >= ord('A'):
				mp[ord(ch) - ord('A')] = 1
			elif ord(ch) <= ord('z') and ord(ch) >= ord('a'):
				mp[ord(ch) - ord('a')] = 1
		for i in range(26):
			if not mp[i]:
				return 0
		return 1


class Solution:

	def checkPangram(self, s):
		alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
		sc = '@#$%^&*()-+?_=,<>/'
		digit = '0123456789'
		l = ''
		for i in range(len(s)):
			if s[i] not in sc:
				if s[i] not in digit:
					if s[i] != ' ':
						l += s[i].lower()
		res = sorted(set(l))
		if res == alphabet:
			return 1
		return 0


class Solution:

	def checkPangram(self, s):
		set_s = set()
		s = s.upper()
		for i in s:
			if 65 <= ord(i) <= 90:
				set_s.add(i)
		if len(set_s) >= 26:
			return 1
		return 0


from collections import defaultdict

class Solution:

	def checkPangram(self, s):
		d = defaultdict(int)
		for i in s:
			o = ord(i)
			if 97 <= o <= 122:
				d[o - 96] = 1
			else:
				d[o - 64] = 1
		for i in range(1, 27):
			if d[i] == 0:
				return False
			else:
				continue
		return True


class Solution:

	def checkPangram(self, s):
		countchar = [0] * 26
		for i in range(len(s)):
			if s[i].isalpha():
				if s[i].islower():
					countchar[ord(s[i]) - ord('a')] += 1
				else:
					countchar[ord(s[i]) - ord('A')] += 1
		for i in range(26):
			if countchar[i] == 0:
				return False
		return True


class Solution:

	def checkPangram(self, s):
		d = {}
		for item in s:
			if item.lower() in d:
				d[item.lower()] += 1
			else:
				d[item.lower()] = 1
		arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
		for item in arr:
			if item not in d:
				return 0
		return 1


class Solution:

	def checkPangram(self, s):
		k = []
		for i in s:
			i = i.lower()
			k.append(i)
		k.sort()
		k = ''.join(k)
		lis = 'abcdefghijklmnopqrstuvwxyz'
		for i in lis:
			if i not in k:
				return False
		return True


class Solution:

	def checkPangram(self, s):
		s = s.lower()
		char = [0] * 26
		for i in range(len(s)):
			if 'a' <= s[i] <= 'z':
				char[ord(s[i]) - ord('a')] += 1
		for i in char:
			if i == 0:
				return 0
		return 1


class Solution:

	def checkPangram(self, s):
		p = set()
		for i in s:
			if i.isalpha():
				p.add(i.lower())
		if len(p) == 26:
			return 1
		return 0


class Solution:

	def checkPangram(self, s):
		s = s.lower()
		alpha = 'abcdefghijklmnopqrstuvwxyz'
		for i in alpha:
			if i not in s:
				return 0
		return 1


class Solution:

	def checkPangram(self, s):
		s = s.lower()
		count = [0] * 256
		for i in range(len(s)):
			count[ord(s[i])] += 1
		for i in range(97, 123):
			if count[i] == 0:
				return 0
		return 1


class Solution:

	def checkPangram(self, s):
		A = 'abcdefghijklmnopqrstuvwxyz'
		s = s.lower()
		for s1 in A:
			if s1 not in s:
				return 0
		return 1


class Solution:

	def checkPangram(self, s):
		A = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
		s = s.upper()
		for alphabet in A:
			if alphabet not in s:
				return False
		return True


class Solution:

	def checkPangram(self, s):
		A = 'abcdefghijklmnopqrstuvwxyz'
		s = s.lower()
		for alphabet in A:
			if alphabet not in s:
				return False
		return True


class Solution:

	def checkPangram(self, s):
		hash = [0] * 26
		for i in range(0, len(s)):
			if s[i] >= 'a' and s[i] <= 'z':
				index = ord(s[i]) - ord('a')
			if s[i] >= 'A' and s[i] <= 'Z':
				index = ord(s[i]) - ord('A')
			hash[index] += 1
		for i in range(0, len(hash)):
			if hash[i] == 0:
				return False
		return True


class Solution:

	def checkPangram(self, s):
		d = dict()
		l = [0] * 26
		sg = 0
		for i in s:
			if i.isalpha() and i not in d.keys():
				d[i] = i
				sg += ord(i.lower())
		if sg == 2847:
			return 1
		return 0


class Solution:

	def checkPangram(self, s):
		A = 'abcdefghijklmnopqrstuvwxyz'
		s = s.lower()
		d = {}
		for i in A:
			d[i] = 0
		for i in s:
			d[i] = d.get(i, 0) + 1
		for i in d.values():
			if i == 0:
				return 0
		return 1


class Solution:

	def checkPangram(self, s):
		if len(s) < 26:
			return 0
		s = s.lower()
		for i in s:
			if not i.isalpha():
				s = s.replace(i, '')
		visited = []
		for j in s:
			if j not in visited:
				visited.append(j)
		if len(visited) == 26:
			return 1
		else:
			return 0


class Solution:

	def checkPangram(self, s):
		check = [-1 for i in range(26)]
		for i in s:
			val = i.lower()
			if ord(val) in range(97, 123):
				check[ord(val) - 97] = 0
		if sum(check) == 0:
			return 1
		else:
			return 0


class Solution:

	def checkPangram(self, s):
		S = s.upper()
		lst = list('ABCDEFGHIJKLNMOPKQRSTUVWXYZ')
		for c in lst:
			if c in S:
				continue
			else:
				ans = 0
				break
		else:
			ans = 1
		return ans


class Solution:

	def checkPangram(self, s):
		a = 'qwertyuiopasdfghjklzxcvbnm'
		s = s.lower()
		s = ' '.join(s)
		for i in a:
			if i not in s:
				return False
		return True


class Solution:

	def checkPangram(self, s):
		s = s.lower()
		a = ''
		for i in s:
			if i.isalpha():
				a = a + i
		if len(set(a)) == 26:
			return 1
		else:
			return 0


class Solution:

	def checkPangram(self, st):
		s = st.lower()
		res = []
		d = {}
		for i in s:
			if i in d:
				d[i] += 1
			else:
				d[i] = 0
		alpha = 'abcdefghijklmnopqrstuvwxyz'
		for i in alpha:
			if i not in d:
				res.append(False)
		if False in res:
			return False
		else:
			return True


class Solution:

	def checkPangram(self, s):
		count = 0
		all = 'qwertyuiopasdfghjklzxcvbnm'
		for i in range(len(all)):
			s = s.lower()
			if all[i] in s:
				count += 1
		if count == 26:
			return 1
		else:
			return 0


class Solution:

	def checkPangram(self, s):
		import re
		s = re.sub('[^a-zA-Z]', '', s).lower()
		for i in range(26):
			curr_char = chr(ord('a') + i)
			if s.find(curr_char) == -1:
				return False
		return True


class Solution:

	def checkPangram(self, s):
		import re
		s = re.sub('[^a-zA-Z]', '', s).lower()
		return len(set(s)) == 26


class Solution:

	def checkPangram(self, s):
		sample = []
		s = s.lower()
		for i in s:
			if i.isalpha():
				if i not in sample:
					sample.append(i)
		if len(sample) != 26:
			return 0
		return 1


class Solution:

	def checkPangram(self, s):
		check = {}
		for i in range(65, 91):
			check[i] = False
		for i in s:
			if i >= 'A' and i <= 'Z' or (i >= 'a' and i <= 'z'):
				letter = i.upper()
				asc = ord(letter)
				check[asc] = True
		for i in range(65, 91):
			if check[i] == False:
				return 0
		return 1


class Solution:

	def checkPangram(self, s):
		s = s.replace(' ', '')
		s = s.lower()
		arr = [0] * 26
		for i in range(len(s)):
			if s[i] >= 'a' and s[i] <= 'z':
				char_ = s[i]
				pos = ord(char_) - ord('a')
				arr[pos] = 1
		for j in arr:
			if j == 0:
				return False
		return True


class Solution:

	def checkPangram(self, s):
		for i in range(26):
			if chr(65 + i) not in s.upper():
				return 0
		return 1


import string

class Solution:

	def checkPangram(self, s):
		distinct = sorted([alpha for alpha in set(s.lower()) if alpha in string.ascii_lowercase])
		if distinct == list(string.ascii_lowercase):
			return 1
		return 0


class Solution:

	def checkPangram(self, s):
		small = 96
		large = 64
		for i in range(26):
			small += 1
			large += 1
			large_char = chr(large)
			small_char = chr(small)
			if large_char not in s and small_char not in s:
				return 0
		return 1


class Solution:

	def checkPangram(self, s):
		l = []
		for x in s:
			if x.isalpha():
				l.append(x.lower())
		alph = []
		for x in range(97, 123):
			alph.append(chr(x))
		for x in l:
			if x in alph:
				alph.remove(x)
		if len(alph) == 0:
			return True
		else:
			return False


import string

class Solution:

	def checkPangram(self, s):
		alphabet = list(string.ascii_lowercase)
		d = {}
		for i in s:
			i = i.lower()
			d[i] = d.get(i, 0) + 1
		for i in alphabet:
			if d.get(i, 0) == 0:
				return 0
		return 1


import string

class Solution:

	def checkPangram(self, s):
		alphabet = list(string.ascii_lowercase)
		c = 0
		s = list(set(s))
		l = [i.lower() for i in s]
		for i in alphabet:
			if i in l:
				c = c + 1
		if c == len(alphabet):
			return 1
		else:
			return 0


class Solution:

	def checkPangram(self, s):
		a = 'abcdefghijklmnopqrstuvwxyz'
		l = []
		for i in s:
			if i.isalpha() and i.lower() in a:
				l.append(i.lower())
		if len(a) == len(set(l)):
			return True
		else:
			return False


class Solution:

	def checkPangram(self, s):
		char_dict = {}
		s = s.lower()
		for i in s:
			if i.isalpha():
				if i in char_dict.keys():
					char_dict[i] += 1
				else:
					char_dict[i] = 0
		if len(char_dict.keys()) == 26:
			return 1
		return 0


class Solution:

	def checkPangram(self, s):
		s = s.lower()
		x = set(s)
		nstr = str(x)
		c = 0
		for i in nstr:
			if i.isalpha():
				c += 1
		if c == 26:
			return 1
		else:
			return 0


class Solution:

	def checkPangram(self, s):
		st = set()
		for i in s:
			if i.isalpha():
				st.add(i.upper())
		chk = set()
		for i in range(65, 91):
			chk.add(chr(i))
		for i in chk:
			if i not in st:
				return False
		return True


class Solution:

	def checkPangram(self, s):
		s1 = set()
		for i in s.lower():
			if i.isalpha():
				s1.add(i)
		return 26 == len(s1)


class Solution:

	def checkPangram(self, s):
		d = {}
		s = s.lower()
		for i in s:
			if i.isalpha():
				if i not in d:
					d[i] = 1
				else:
					d[i] += 1
		if len(d) == 26:
			return True
		return False


import string

class Solution:

	def checkPangram(self, s):
		res = []
		s1 = s.lower()
		s1 = list(map(str, s1))
		for ele in s1:
			if ele == ' ' or ele == ',':
				s1.remove(ele)
		s2 = string.ascii_lowercase
		s2 = list(map(str, s2))
		for ele in s2:
			if ele not in s1:
				res.append(ele)
		if len(res) == 0:
			return True
		else:
			return False


class Solution:

	def checkPangram(self, st):
		n = len(st)
		s = set()
		count = 0
		for i in range(n):
			val = ord(st[i])
			ch = st[i].lower()
			if (65 <= val <= 90 or 97 <= val <= 122) and ch not in s:
				s.add(st[i].lower())
				count += 1
		return count == 26


import string

class Solution:

	def checkPangram(self, s):
		s = s.lower()
		for i in string.ascii_lowercase:
			if i not in s:
				return 0
		return 1


class Solution:

	def checkPangram(self, s):
		l = [0] * 26
		for i in range(len(s)):
			if ord(s[i]) >= 65 and ord(s[i]) <= 90:
				l[ord(s[i]) - 65] += 1
			elif ord(s[i]) >= 97 and ord(s[i]) <= 122:
				l[ord(s[i]) - 97] += 1
		for i in range(26):
			if l[i] == 0:
				return False
		return True


class Solution:

	def checkPangram(self, s):
		a = 'abcdefghijklmnopqrstuvwxyz'
		s = s.lower()
		for i in a:
			if i not in s:
				return False
		return True