package
0.0.0-20241220224003-b7cf03a90b2b
Repository: https://github.com/szhou12/leetcode-go.git
Documentation: pkg.go.dev
# README
205. Isomorphic Strings
Solution idea
Use two HashMaps:
map dict
: map each char in s
to the char of the same position in t
. map dict
is to check that if there is a repeated char in s
, it must be mapped to the same char that was previously mapped to in t
.
map checkDups
: a set that contains all chars in t
that have been scanned. map checkDups
is to ensure "No two characters may map to the same character".
Time complexity = $O(n)$
Exactly same idea as 290. Word Pattern