Description

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, preserving order.

Examples

Input:s = "egg", t = "add"
Output:true
Explanation:

e->a, g->d mapping.

Input:s = "foo", t = "bar"
Output:false
Explanation:

In s, 'o' maps to both 'a' and 'r' in t (positions 1 and 2). Inconsistent mapping.

Input:s = "paper", t = "title"
Output:true
Explanation:

Mapping: p->t, a->i, e->l, r->e. Each character maps consistently.

Constraints

  • 1 ≤ s.length ≤ 5 × 10⁴

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!