Isomorphic Strings

Leetcode 205.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Solution {
public boolean isIsomorphic(String s, String t) {
int[] s1 = new int[256];
int[] t1 = new int[256];
for(int i = 0; i < s.length();i++){
char sc = s.charAt(i);
char tc = t.charAt(i);
if(s1[sc] != t1[tc])
return false;
s1[sc] = i + 1;
t1[tc] = i + 1;
}
return true;
}
}