Isomorphic Strings
Given two strings s and t, determine if they are isomorphic.
Two strings are isomorphic if the characters in s can be replaced to get t.
All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character but a character may map to itself.
Example
Given s = "egg"
, t = "add"
, return true
.
e-> a, g-> d, g -> d true
Given s = "foo"
, t = "bar"
, return false
.
f-> b, o -> a, o-> r 不能一个字母映射两个
Given s = "paper"
, t = "title"
, return true
.
p->t, a -> i, p -> t, e -> l, r -> e true;
s里的每一个字母都映射着t里的一个字母
时间复杂度 o(N)
Last updated