First Non-Repeating Character
Easy 20 XPStringsHashing
Commonly asked at Amazon, Zoho, Microsoft
Read a word and print the first character that appears exactly once. If every character repeats, print -1.
- Input
- One word (lowercase letters).
- Output
- The character, or -1.
Sample 1
Input
swiss
Output
w
Sample 2
Input
aabb
Output
-1
Read input with input() (no prompt message) and print only the answer. Run tries the Input box; Submit checks all test cases.
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.The solution unlocks after 3 submissions.