Skip to content

Commit fba5cb5

Browse files
authored
Create string-transforms-into-another-string.py
1 parent b2a6770 commit fba5cb5

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
import itertools
5+
6+
7+
class Solution(object):
8+
def canConvert(self, str1, str2):
9+
"""
10+
:type str1: str
11+
:type str2: str
12+
:rtype: bool
13+
"""
14+
if str1 == str2:
15+
return True
16+
lookup = {}
17+
for i, j in itertools.izip(str1, str2):
18+
if lookup.setdefault(i, j) != j:
19+
return False
20+
return len(set(str2)) < 26

0 commit comments

Comments
 (0)