Challenge: First Unique Letter
Completed
Read a word and print the first letter that appears only once in it, or none.
Input
One word.
Output
A single letter, or none.
Example
Input
leetcode
Output
l
Editor
Python
Hints
Count every letter first.
Then walk the word again and stop at the first letter with count 1.
Solution explanation
Two passes over the word: O(n).
Show solution
from collections import Counter
s = input().strip()
c = Counter(s)
for ch in s:
if c[ch] == 1:
print(ch)
break
else:
print("none") Output
Answer
You can practice without logging in. Log in to save completion.
Save your progress
You're practising as a guest, so your progress won't be saved.
- Track every lab you complete
- Earn verifiable lab certificates
- See your progress in every module