import 'package:test/test.dart';
bool isIsomorphic(String string1, String string2) {
Map<String, String> sMap = {};
Map<String, String> tMap = {};
for (int i = 0; i < string1.length; ++i) {
String s = string1[i];
String c = string2[i];
if (!sMap.containsKey(s) && !tMap.containsKey(c)) {
sMap[s] = c;
tMap[c] = s;
}
else if (!sMap.containsKey(s) || !tMap.containsKey(c)) {
return false;
}
else if (sMap[s] != c || tMap[c] != s) {
return false;
}
}
return true;
}
void main() {
test('test case 1', () => expect(isIsomorphic('egg', 'add'), true));
test('test case 2', () => expect(isIsomorphic('foo', 'bar'), false));
test('test case 3', () => expect(isIsomorphic('paper', 'title'), true));
}