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:
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))
I did the same thing initially, and I wasn't getting the right answer in all test cases. But after seeing your snippet, I figured it out.
I did it the long way in Python. https://www.hackerrank.com/challenges/gem-stones/submissions/code/12761430