Skip to content

Practice Isomorphic Strings

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#205
LeetCode Problem

Isomorphic Strings

Problem Statement

Given two strings s and t, determine if they are isomorphic. Two strings s and t 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.

Source: Isomorphic Strings on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

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

# Example 2

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

# Example 3

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

Constraints

1 <= s.length <= 5 * 10^4
t.length == s.length
s and t consist of any valid ascii character.

Related LeetCode Problems

Practice more problems similar to Isomorphic Strings.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.