using System.Collections.Generic;
public bool IsIsomorphic(string s, string t) {
if(s.Length != t.Length){
Dictionary<char,char> relation = new Dictionary<char,char>();
for(int i = 0 ; i < s.Length ; i++)
char c, sChar = s[i], tChar = t[i];
if(relation.TryGetValue(sChar,out c)){
else if(relation.ContainsValue(tChar)){
relation.Add(sChar,tChar);
public static void Main()
Program p = new Program();
Console.WriteLine(p.IsIsomorphic("egg","add") ? "True" : "False");
Console.WriteLine(p.IsIsomorphic("foo","bar") ? "True" : "False");
Console.WriteLine(p.IsIsomorphic("paper","tiale") ? "True" : "False");