Roy wanted to increase his typing speed for programming contests. So, his friend advised him to type the sentence "The quick brown fox jumps over the lazy dog" repeatedly, because it is a pangram. (Pangrams are sentences constructed by using every letter of the alphabet at least once.) After typing the sentence several times, Roy became bored with it. So he started to look for other pangrams. Given a sentence s, tell Roy if it is a pangram or not. Input Format Input consists of a line containing s.
Length of s can be at most 103 \$(1≤|s|≤103)\$ and it may contain spaces, lower case and upper case letters. Lower case and upper case instances of a letter are considered the same.
from collections import defaultdict import string def is_pangram(astr): lookup = defaultdict(int) for char in astr: lookup[char.lower()] += 1 for char in string.ascii_lowercase: if lookup[char] == 0: return False return True print "pangram" if is_pangram(raw_input()) else "not pangram"
from collections import Counter import string def is_pangram(astr): counter = Counter(astr.lower()) for char in string.ascii_lowercase: if counter[char] == 0: return False return True print "pangram" if is_pangram(raw_input()) else "not pangram"
Which is better in terms of running time and space complexity?