Guest User

Untitled

a guest
Nov 18th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. class Solution {
  2. public boolean isIsomorphic(String s, String t) {
  3. if(s == null) {
  4. return true;
  5. }
  6.  
  7. final int len = s.length();
  8. int[] table_1 = new int[256];
  9. int[] table_2 = new int[256];
  10.  
  11. for(int i = 0; i < len; ++i) {
  12. if(table_1[s.charAt(i)] != table_2[t.charAt(i)]) {
  13. return false;
  14. }
  15.  
  16. table_1[s.charAt(i)] = i+1;
  17. table_2[t.charAt(i)] = i+1;
  18. }
  19.  
  20. return true;
  21. }
  22. }
Add Comment
Please, Sign In to add comment