Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Isomorphic Strings
Bookmark
Brute Force
Two Hash Maps
Last Seen Index
Input
Isomorphic
s-side clash
t-side clash
Longer match
Custom
s
=
egg
,
t
=
add
s
t
e
g
g
a
d
d
0
1
2
equal s-chars must line up with equal t-chars, for every pair
s
t
e
g
g
a
d
d
0
1
2
equal s-chars must line up with equal t-chars, for every pair
s
t
e
g
g
a
d
d
0
1
2
len(s)
3
=
3
s
t
e
g
g
a
d
d
0
1
2
fix i = 0, compare
'e'/'a'
with later columns
s
t
≠
e
g
g
a
d
d
i
j
0
1
2
≠
s: different, t: different
→ agree
s
t
≠
e
g
g
a
d
d
i
j
0
1
2
≠
s: different, t: different
→ agree
s
t
e
g
g
a
d
d
0
1
2
fix i = 1, compare
'g'/'d'
with later columns
s
t
=
e
g
g
a
d
d
i
j
0
1
2
=
s: equal, t: equal
→ agree
s
t
e
g
g
a
d
d
0
1
2
return
true
algo
master
.
io
Step:
Check every pair: equal s-chars must line up with equal t-chars
0 / 7
Input
Isomorphic
s-side clash
t-side clash
Longer match
Custom
s
=
egg
,
t
=
add
0 / 7
algo
master
.
io
Step:
Check every pair: equal s-chars must line up with equal t-chars