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.
importsysdefrstripped(fh):forlineinfh:yieldline.rstrip()next(sys.stdin)# Ignore first lineclean_stdin=rstripped(sys.stdin)gemstones=set(next(clean_stdin))forlineinclean_stdin:gemstones.intersection_update(list(line))print(len(gemstones))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Gemstones
You are viewing a single comment's thread. Return to all comments →
Here's a more memory efficient version: