• + 0 comments
    def twoStrings(s1, s2):
        x=list(set(s1))
        y=list(set(s2))
        for i in x:
            for j in y:
                if i==j:
                    return 'YES'
        return 'NO'
    

    or

    def twoStrings(s1, s2):
        set1 = set(s1)
        set2 = set(s2)
        return "YES" if set1 & set2 else "NO"
    

    or

    def twoStrings(s1, s2):
        def bitmask(s):
            bitmask = 0
            for char in s:
                bitmask |= (1 << (ord(char) - ord('a')))
            return bitmask
        bm1 = bitmask(s1)
        bm2 = bitmask(s2)
        return "YES" if bm1 & bm2 else "NO"