/// <summary>
/// Uses letterCount array to record each letter's cout, count of letter 'a' stored in letterCount[0],
/// count of letter 'b' stored in letterCount[1], count of letter 'c' stored in letterCount[2], etc.
/// The complexity of this algorism is O(n).
/// </summary>
/// <param name="s"></param>
private static void FindFirstNotDuplicatedLetter(string s)
{
int[] letterCount = new int[26];
for (int i = 0; i < s.Length; i++)
{
letterCount[s[i] - 'a']++;
}
bool found = false;
for (int i = 0; i < s.Length; i++)
{
if (letterCount[s[i] - 'a'] == 1)
{
found = true;
Console.WriteLine(s[i]);
break;
}
}
if (!found)
Console.WriteLine("No not duplicated letter.");
}