First Unique Character

Sometimes you need to find the first character that appears only once in a string, such as the first unique letter in a code, name, or message. Given a string s, return the index of the first non-repeating character. If every character repeats, return -1.

Примеры

Ввод
"leetcode"
Вывод
0
Ввод
"loveleetcode"
Вывод
2
Ввод
"aabb"
Вывод
-1

Нужно реализовать

def first_uniq_char(s: str) -> int:

Теги

stringshashmap
PostgreSQLv16

Tutaj pojawi się wynik wykonania kodu

Visible tests
1
Input
"leetcode"
Expected0
2
Input
"loveleetcode"
Expected2
3
Input
"aabb"
Expected-1
4
Input
"z"
Expected0
5
Input
"aadadaad"
Expected-1
6
Input
" "
Expected-1
Focus radio
Paused · SomaFM · Fluid