Facebook
From hung, 1 Month ago, written in Dart.
Embed
Download Paste or View Raw
Hits: 139
  1. class Solution {
  2.   bool isIsomorphic(String s, String t) {
  3.     Map<String, String> map = Map<String, String>();
  4.     for (int i = 0; i < s.length; i++) {
  5.       if (map.containsKey(s[i])) {
  6.         if (map[s[i]] != t[i]) {
  7.           return false;
  8.         }
  9.       } else if (map.containsValue(t[i])) {
  10.         return false;
  11.       } else {
  12.         map[s[i]] = t[i];
  13.       }
  14.     }
  15.     return true;
  16.   }
  17. }
  18.