You are viewing a single comment's thread. Return to all comments →
int letterBits(const string &s) { int bits = 0; for (char ch : s) bits |= 1 << (ch - 'a'); return bits; } int main() { int testCases; cin >> testCases; while (testCases--) { string strA, strB; cin >> strA >> strB; int bitsA = letterBits(strA); int bitsB = letterBits(strB); cout << (bitsA & bitsB ? "YES": "NO") << endl; } return 0; }
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 →