Implement the method firstNonRepeatingChar that returns the first non-repeating character in a string.
Return the first character that appears exactly once in the string. The first unique character is determined by original order.
The task is designed to test careful handling of edge cases, not only the most common input.
- Return
#if every character repeats. - Character matching is case-sensitive.
- Spaces and punctuation are treated like normal characters when they appear.
Count the frequency of every character, then scan the string again and return the first character whose frequency is one.