6 May 2024 Shift 2 — First Non-Repeating Character
E · easyP · Verified PYQstringshashing
Problem
Given a string, find the first character that does not repeat. If all characters repeat, print -1.
Example
Input
aabbcde
Output
c
Use OrderedDict or two-pass: first build frequency dict, then scan string left-to-right for freq==1.