#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param str string字符串
# @return int整型
#
class Solution:
def FirstNotRepeatingChar(self , str: str) -> int:
if len(str) == 1:
return -1
hash = dict()
for i in str:
if i in hash.keys():
hash[i] += 1
else:
hash[i] = 1
for key,value in hash.items():
if value == 1:
return str.index(key)
return -1

京公网安备 11010502036488号