Skip to content

Commit 120941a

Browse files
committed
Time: 7 ms (86.15%), Space: 42.9 MB (67.14%) - LeetHub
1 parent b75459d commit 120941a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
public boolean isIsomorphic(String s, String t) {
3+
int[] s1 = new int[256];
4+
int[] s2 = new int[256];
5+
for (int i = 0; i < s.length(); i++) {
6+
char c1 = s.charAt(i);
7+
char c2 = t.charAt(i);
8+
if (s1[c1] != s2[c2]) {
9+
return false;
10+
}
11+
s1[c1] = i + 1;
12+
s2[c2] = i + 1;
13+
}
14+
return true;
15+
}
16+
}

0 commit comments

Comments
 (0)