Answers for "Check if One String Swap Can Make Strings Equal"

0

Check if One String Swap Can Make Strings Equal

def areAlmostEqual(self, s1: str, s2: str) -> bool:
        if s2 == s1: return True

        for k in set(s1):
            if k not in s2: return False
        
        cnt = 0
        for i in range(len(s1)):
            if s1[i] != s2[i]:
                cnt += 1
        return cnt == 2
Posted by: Guest on August-30-2021

Code answers related to "Check if One String Swap Can Make Strings Equal"

Browse Popular Code Answers by Language