what is your simplest algorithm to find duplicate chars?
string a = "school";
string b = "ofrock";
output should be o,c (not ooc). can you find O(n) linear complexity? I can't
string a = "School";
string b = "ofRock";
string c = a + b;
char[] cc = c.ToCharArray();
Dictionary<char, int> d = new Dictionary<char, int>();
Dictionary<char, int> l = new Dictionary<char, int>();
foreach (char ccc in cc)
{
try
{
d.Add(ccc, 1);
}
catch
{
try
{
l.Add(ccc, 1);
}
catch
{
}
}
}