One-to-One Letter Cipher
A substitution cipher replaces every occurrence of a character with another character. Two different characters may never map to the same character, and a character may map to itself.
Given strings s and t of equal length, return true if some such cipher turns s into t.
Example 1
Input: s = "egg", t = "add" Output: true
Example 2
Input: s = "foo", t = "bar" Output: false Explanation: `o` would have to map to both `a` and `r`.
Constraints
- 0 <= s.length == t.length <= 5 * 10^4
- Both strings contain printable ASCII characters.
Hint 1
Keep a map in each direction.
Hint 2
A conflict in either map means the cipher is impossible.
Good practice for: Frontend Developer, Backend Developer, Full Stack Developer, Mobile App Developer, Automation Test Engineer, Blockchain Developer
Run checks your code on 2 sample tests. Submit runs all 8 tests, including hidden ones, and earns points. Use console.log to debug. Python's first run can take a few seconds while it starts.