Isomorphic String
Given two strings, determine if they are isomorphic. Two strings are "isomorphic" if each unique character from the first string can be replaced to match the second string, without changing the ordering of the characters.
Different characters must map to different characters, but a character can map to itself.
Input
str_1
: the first string.str_2
: the second string.
Output
Whether if these two strings are isomorphic.
Examples
Example 1:
Input:
1str_1 = "egg" 2str_2 = "all"
Output: true
Explanation:
"e" can be replaced with "a" and "g" can be replaced with "l". Therefore, the strings are isomorphic.
Example 2:
Input:
1str_1 = "wow" 2str_2 = "aaa"
Output: false
Explanation:
"w" and "o" both maps to "a", which makes them not isomorphic.
Constraints
1 <= len(str_1), len(str_2) <= 5 * 10^4
- The strings are case sensitive and consists of valid ASCII characters.
Try it yourself
Solution
Title
Script
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
Ipsum
has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
Contrary to popular belief, Lorem
Ipsum
is not simply random text.
1 >>> a = [1, 2, 3] 2 >>> a[-1] 3 3