def isOneEditDistance(self, s, t):
        """
        Iterator version
        """
        m, n = len(s), len(t)
        if m > n: return self.isOneEditDistance(t, s)
        if n-m > 1: return False

        diff = 0
        i, j = iter(s), iter(t)
        a, b = next(i, None), next(j, None)
        while a and b and diff < 2:
            if a == b:
                a, b = next(i, None), next(j, None)
            else:
                if m != n:
                    b = next(j, None)
                else:
                    a, b = next(i, None), next(j, None)

                diff += 1

        return diff == 1 or diff == 0 and m != n
dataset/ETHPy150Open algorhythms/LeetCode/161 One Edit Distance.py/Solution1.isOneEditDistance/original