Isomorphic Strings
Problem statement
Given two strings first and second, return true when characters of first can be replaced to obtain second.
Every occurrence of one source character must map to the same target character, and two different source characters may not map to the same target character. Character order is preserved.
Function
areIsomorphic(first: String, second: String) → booleanExamples
Example 1
first = "egg"second = "add"return = truee maps to a and g maps to d.
Example 2
first = "foo"second = "bar"return = falseo would need to map to both a and r.
Example 3
first = "aaa"second = "XYZ"return = falseThe same source character cannot map to three targets.
Constraints
0 <= first.length, second.length <= 200000.- Strings contain ASCII characters.