text of lowercase English letters. Find the leftmost letter that occurs in the string exactly once and return its index (0-based).
If every letter occurs at least twice, return -1.text="teapot" → 1
t occurs twice, while e at index 1 occurs only once.
text="abcabd" → 2
a and b repeat; the first letter without a twin is c at index 2.
text="xyxy" → -1
Every letter appears twice, so the answer is -1.
text consists of lowercase English letterstext="teapot"
1
Run checks the first 3 tests in your browser. Submit checks all 93 tests on the server, hidden ones included.