public class Solution {
public bool IsIsomorphic(string s, string t) {
if (s.Length != t.Length)
{
return false;
}
else
{
Dictionary<char, int> dic1 = new Dictionary<char, int>();
Dictionary<char, int> dic2 = new Dictionary<char, int>(); int type1 = ;
int type2 = ; StringBuilder sb1 = new StringBuilder();
StringBuilder sb2 = new StringBuilder(); foreach (var c in s)
{
if (!dic1.ContainsKey(c))
{
dic1.Add(c, type1);
sb1.Append(type1);
type1++;
}
else
{
sb1.Append(dic1[c]);
} } foreach (var c in t)
{
if (!dic2.ContainsKey(c))
{
dic2.Add(c, type2);
sb2.Append(type2);
type2++;
}
else
{
sb2.Append(dic2[c]);
}
} if (sb1.ToString() != sb2.ToString())
{
return false;
}
else
{
return true;
}
}
}
}
https://leetcode.com/problems/isomorphic-strings/#/description