Problem
Return the index of the first character in text that appears exactly once. Case matters.
Implement first_unique_index(text).
Input
text: The text to inspect.
Output
Return the index, or -1 if every character repeats.
Constraints
0 ≤ length ≤ 100,000
Examples
Example 1
Input:
text = "swiss"
Expected output:
expected = 1
Input:
std::string text = "swiss";
Expected output:
long long expected = 1;
Input:
string text = "swiss";
Expected output:
long expected = 1;
Explanation
s repeats, w appears once at index 1.
Example 2
Input:
text = "aabb"
Expected output:
expected = -1
Input:
std::string text = "aabb";
Expected output:
long long expected = -1;
Input:
string text = "aabb";
Expected output:
long expected = -1;
Explanation
Every character repeats: -1.
References
This challenge is adapted for CodeUtility. Follow the statement and constraints above.