First Unrepeated Badge
easySecurity logs every badge swipe at the office door as a single lowercase letter per employee. Most people swipe in and out — appearing multiple times — but the auditor wants the first person who swiped exactly once all day.
Given the swipe string swipes, return the index of the first character that appears exactly once in the whole string. If every character repeats, return -1.
Example 1
in swipes = "ababcd"
out 4
'a' and 'b' both repeat; 'c' at index 4 is the first character appearing exactly once.
Example 2
in swipes = "aabb"
out -1
Everyone swiped twice.
Constraints
- · 1 <= len(swipes) <= 10^5
- · swipes contains only lowercase English letters
solution.py● loading python…
test results
Hit ▶ Run to test your code against the visible cases.