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:
trueExplanation:
e->a, g->d mapping.
Input:
s = "foo", t = "bar"Output:
falseExplanation:
In s, 'o' maps to both 'a' and 'r' in t (positions 1 and 2). Inconsistent mapping.
Input:
s = "paper", t = "title"Output:
trueExplanation:
Mapping: p->t, a->i, e->l, r->e. Each character maps consistently.
Constraints
- •
1 ≤ s.length ≤ 5 × 10⁴