- 用s.count()函数计算元素出现的个数,用index()求出元素的位置
class Solution: def FirstNotRepeatingChar(self, s): if s == '': return -1 for i in s: if s.count(i) == 1: return s.index(i) return -1
class Solution: def FirstNotRepeatingChar(self, s): if s == '': return -1 for i in s: if s.count(i) == 1: return s.index(i) return -1