問題
翻訳を表示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.
制約
0 ≤ length ≤ 100,000
例
例 1
入力:
text = "swiss"
期待される出力:
expected = 1
入力:
std::string text = "swiss";
期待される出力:
long long expected = 1;
入力:
string text = "swiss";
期待される出力:
long expected = 1;
解説
s repeats, w appears once at index 1.
例 2
入力:
text = "aabb"
期待される出力:
expected = -1
入力:
std::string text = "aabb";
期待される出力:
long long expected = -1;
入力:
string text = "aabb";
期待される出力:
long expected = -1;
解説
Every character repeats: -1.
参考資料
この課題はCodeUtility用に調整されています。上記の説明と制約に従ってください。