string str = "idempotent";
Dictionary<string, int> keyValuePairs = new Dictionary<string, int>();
char[] strChar = str.ToCharArray();
foreach(char c in strChar)
{
if(keyValuePairs.Where(x=>x.Key==c.ToString()).Any())
{
keyValuePairs[c.ToString()] = keyValuePairs[c.ToString()] + 1;
}
else
{
keyValuePairs.Add(c.ToString(), 1);
}
}
foreach(KeyValuePair<string,int> k in keyValuePairs)
{
Console.WriteLine(k.Value);
}
No comments:
Post a Comment