# Time O(m*n) Space O(1)
def isOne(s, t):
    m, n = len(s), len(t)
    if m > n:
        return isOne(t, s)
    if n - m > 1:
        return False
    i, shift = 0, n-m
    while i<m and s[i] == t[i]:
        i += 1
    if shift == 0:
        i += 1
    while i<m and s[i] == t[i+shift]:
        i += 1
    
    return i == m

if __name__ == '__main__':
    s = 'teachd'
    t = 'teache'
    print(isOne(s,t))
    print(isOne('','a'))
    print(isOne('',t))
