Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static char? traverse(string s, bool caseInsensitiveMatching = true)
- {
- var counts = new Dictionary<char, int>();
- for(int characterIndex=0; characterIndex < s.Length; characterIndex++)
- {
- var c_upper = s[characterIndex];
- if(!caseInsensitiveMatching)
- c_upper = char.ToUpper(s[characterIndex]);
- if (counts.ContainsKey(c_upper))
- counts[c_upper] = -1;
- else
- counts[c_upper] = characterIndex;
- }
- foreach (var kvp in counts)
- if (kvp.Value > -1)
- return s[kvp.Value];
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement