You are viewing a single comment's thread. Return to all comments →
timeit says that using any() is a significant slower way than
return ('NO' if s1.isdisjoint(s2) else 'YES')
which is faster than
return ('YES' if (s1 & s2) else 'NO')
or using a for loop:
found = 'NO' for i in s1: if i in s2: found = 'YES' break return found
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 →
timeit says that using any() is a significant slower way than
which is faster than
or using a for loop: