# LeetCode Isomorphic Strings

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.

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.

For example,
Given "egg""add", return true.

Given "foo""bar", return false.

Given "paper""title", return true.

Solution:

import java.util.*;

public class Solution {
public boolean isIsomorphic(String s, String t) {

int prePosition1[] = new int[1000];
int prePosition2[] = new int[1000];

Arrays.fill(prePosition1, -1);
Arrays.fill(prePosition2, -1);

int ch1, ch2;

for (int i = 0; i < s.length(); i++) {
ch1 = s.charAt(i);
ch2 = t.charAt(i);
if (prePosition1[ch1] == prePosition2[ch2]) {
prePosition1[ch1] = i;
prePosition2[ch2] = i;
} else {
return false;
}

}

return true;
}
}

#### LeetCode 205:Isomorphic Strings

2015-05-08 23:06:25

#### leetcode 205: Isomorphic Strings

2015-04-30 04:54:59

#### 【LeetCode】205 Isomorphic Strings （c++实现）

2015-07-22 10:29:55

#### 205. Isomorphic Strings [easy] (Python)

2016-06-15 14:02:47

#### 关于LeetCode中Isomorphic Strings一题的理解

2016-09-07 18:31:53

#### 【leetcode】205. Isomorphic Strings（Python & C++）

2017-08-25 21:27:15

#### (LeetCode)Isomorphic Strings --- 同构字符串

2016-08-18 10:06:27

#### 【LeetCode-面试算法经典-Java实现】【205-Isomorphic Strings（同构字符串）】

2015-08-27 06:33:32

#### [leetcode-205]Isomorphic Strings(java)

2015-08-26 19:35:56

#### [leetcode: Python]205. Isomorphic Strings

2017-05-12 12:39:26