Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public boolean isIsomorphic(String s, String t) {
- if(s == null) {
- return true;
- }
- final int len = s.length();
- int[] table_1 = new int[256];
- int[] table_2 = new int[256];
- for(int i = 0; i < len; ++i) {
- if(table_1[s.charAt(i)] != table_2[t.charAt(i)]) {
- return false;
- }
- table_1[s.charAt(i)] = i+1;
- table_2[t.charAt(i)] = i+1;
- }
- return true;
- }
- }
Add Comment
Please, Sign In to add comment