We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Much nicer than what I did originally in python, but I'm pretty new still! Though this question has 1 <= N <= 100, if N could be much larger, it would be better not to save the entire list in memory, albeit temorarily. It's longer, but stores much less. Just thought I'd share. :D
n = int(raw_input())
intersection_chars = set(raw_input())
for _ in range(n-1):
rock = set(raw_input())
intersection_chars.intersection_update(rock)
Gemstones
You are viewing a single comment's thread. Return to all comments →
Much nicer than what I did originally in python, but I'm pretty new still! Though this question has 1 <= N <= 100, if N could be much larger, it would be better not to save the entire list in memory, albeit temorarily. It's longer, but stores much less. Just thought I'd share. :D
n = int(raw_input()) intersection_chars = set(raw_input()) for _ in range(n-1): rock = set(raw_input()) intersection_chars.intersection_update(rock)
print len(inters_chars)