6 May 2024 Shift 2 — First Non-Repeating Character

E · easyP · Verified PYQstringshashing

Given a string, find the first character that does not repeat. If all characters repeat, print -1.

Input
aabbcde
Output
c
Use OrderedDict or two-pass: first build frequency dict, then scan string left-to-right for freq==1.
← 6 May 2024 Shift 1 — Count Subarrays with Sum = K8 May 2024 (Advanced) — Password Validator + Caesar Cipher →
Report an issue with this question