time O(N) space O(26)
be aware of test case “abcdefghijklmnopqrstuvwxyz” “bcdefghijklmnopqrstuvwxyzq” where a in str1 not exists in str2; z–map-> q; p –map->q
class Solution:
def canConvert(self, str1: str, str2: str) -> bool:
if str1 == str2:
return True
d = {}
for i,j in zip(str1,str2):
d[i] = d.get(i,j)
if d[i] != j:
return False
return len(set(str2)) < 26 # here can't be str1