Notes

Personal notes on various topics

View on GitHub

Isomorphic Strings

Problem Statement

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, with the following conditions:

Examples

Example 1:

Input:  s = "egg", t = "add"
Output: true
Explanation: 
Mapping 'e' to 'a' and 'g' to 'd' makes the strings identical.

Example 2:

Input:  s = "foo", t = "bar"
Output: false
Explanation: 
The character 'o' would need to map to both 'a' and 'r', which is not allowed.

Example 3:

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

Constraints

Code Template

class Solution:
    def isIsomorphic(self, s: str, t: str) -> bool:
        # Your code here
        pass

Solutions

Back to Problem List Back to Categories