728x90
https://leetcode.com/problems/isomorphic-strings
class Solution:
def isIsomorphic(self, s: str, t: str) -> bool:
mapping = {}
for i, c in enumerate(s):
if mapping.get(c, None) is None:
if t[i] in mapping.values():
return False
mapping[c] = t[i]
else:
if mapping[c] != t[i]:
return False
return True
728x90
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 1544. Make The String Great (0) | 2024.04.05 |
---|---|
[Leetcode] 938. Range Sum of BST (0) | 2024.04.05 |
[Leetcode] 58. Length of Last Word (1) | 2024.04.01 |
[Leetcode] 3099. Harshad Number (0) | 2024.03.31 |
[Leetcode] 2962. Count Subarrays Where Max Element Appears at Least K Times (0) | 2024.03.29 |