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.
This is rather easy to solve in Python. All you need is to convert each string into a set and find the intersection of those sets using reduce. Here's the snippet:
def find_intersection(values):
all_uniques = []
for value in values:
all_uniques.append(set([l for l in value]))
return len(reduce(lambda x, y: x & y all_uniques))
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 →
This is rather easy to solve in Python. All you need is to convert each string into a set and find the intersection of those sets using reduce. Here's the snippet: