第一次遍历:建立哈希表,以单个字符为Key,以字符出现次数为Value第二次遍历:搜索出现次数为1的字符,返回位置;若查完都无,则返回-1 # -*- coding:utf-8 -*- class Solution: def FirstNotRepeatingChar(self, s): res = {} for i in range(len(s)): if res.get(s[i]) == None: res[s[i]] = 1 else: ...