File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,38 @@ class Solution(object):
133133 return max_length
134134```
135135
136+ ## 205. 同构字符串
137+
138+ [ 原题链接] ( https://leetcode-cn.com/problems/isomorphic-strings/ )
139+
140+ ### 思路
141+
142+ 双哈希表 + 双指针。
143+
144+ ``` python
145+ class Solution :
146+ def isIsomorphic (self , s : str , t : str ) -> bool :
147+ length1 = len (s)
148+ length2 = len (t)
149+ if length1 != length2:
150+ return False
151+ table1 = dict ()
152+ table2 = dict ()
153+ for i in range (length1):
154+ if s[i] not in table1:
155+ # 没有映射过
156+ table1[s[i]] = t[i]
157+ # 判断是否进行了相同映射
158+ if t[i] in table2:
159+ return False
160+ table2[t[i]] = s[i]
161+ else :
162+ # 映射过了
163+ if t[i] != table1[s[i]]:
164+ # 映射的字母不同
165+ return False
166+ return True
167+ ```
136168
137169## 217. 存在重复元素
138170
You can’t perform that action at this time.
0 commit comments