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 solution can be optimized. At the worst case you will scan both strings 26 times. A better optimized solution, is to scan first string, and populate a set of unique characters that appeared in it. Then scan second string and check if any character in it is in the set of unique characters you populated from the first string.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Two Strings
You are viewing a single comment's thread. Return to all comments →
This solution can be optimized. At the worst case you will scan both strings 26 times. A better optimized solution, is to scan first string, and populate a set of unique characters that appeared in it. Then scan second string and check if any character in it is in the set of unique characters you populated from the first string.