> For the complete documentation index, see [llms.txt](https://emmaguo100.gitbook.io/leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://emmaguo100.gitbook.io/leetcode/05-04-2022.md).

# 05/04/2022

For each character in the given string, we replace it with the index of that character's first occurence in the string.

Two strings are isomorphic if the positions of the characters follow the same pattern. So I'm using maps to compare the position patterns.

For example:

```
String 1:              A B E A C D B
index pattern:         0 1 2 0 4 5 1
String 2:              X Y I X H K Y
index pattern:         0 1 2 0 4 5 1
```

Whether the two strings are isomorphic can be judged by the index patterns. In the above example, these two strings are isomorphic with the same index patterns.

<br>
