Isomorphic Strings

EasyStringSorting

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:

Character mapping: e→a, g→d. 'egg' maps to 'add' with consistent one-to-one character replacement.

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 and sharpen your skills for technical interviews.