Loading...
Loading...
Loading...
A log scanner looks for the first character that appears exactly once in a line. Print its position (counting from 0), or -1 if every character repeats.
Example 1
Input
mentornxtmentoring
Output
7
x is first with one copy, at position 7.
Example 2
Input
aabb
Output
-1
Every letter repeats.
Try the problem first. Open one hint at a time.
Count all letters in one pass.
Then scan the word in order and stop at the first letter with count 1.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor