• + 0 comments

    python O(n + m) time O(n) space:

    def twoStrings(s1, s2):
        strset = set(s1)
        
        for c in s2:
            if c in strset:
                return "YES"
        
        return "NO"