You are viewing a single comment's thread. Return to all comments →
C++ solution :
string twoStrings(string s1, string s2) { int freq1[26], freq2[26]; for (int i=0;i<26;i++) freq1[i]=freq2[i]=0; for (char ch:s1) freq1[ch-'a']++; for (char ch:s2) freq2[ch-'a']++; for (int i=0;i<26;i++) if (freq1[i]&&freq2[i]) return "YES"; return "NO"; }
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 →
C++ solution :