Return the first non-repeating character in a string, or `None` when every character repeats.
Answer
Count each character first, then scan the original string in its existing order and return the first character whose count is one. Counter makes the counting step explicit, while the second pass is necessary because a frequency table alone does not tell you which unique character appeared first in the original text.
Strong answer includes
- counts characters first
- performs a second ordered pass
- returns None when no unique character exists
Practical example
Python
Result
Run the code to see the result.
The generator expression scans characters lazily in original order and next(..., None) provides the no-match result.
Expected result: w, then None.