Loading problem…
You're building a form validation system that needs to check if two strings follow the same character mapping pattern. This is useful for validating password patterns, detecting similar structures, or matching templates.
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.
isIsomorphic("egg", "add"); // true - e→a, g→d
isIsomorphic("foo", "bar"); // false - o→a and o→r (conflict)
isIsomorphic("paper", "title"); // true - p→t, a→i, e→l, r→eThis problem models real validation scenarios: