【leetcode❤python】387. First Unique Character in a String
#-*- coding: UTF-8 -*-
class Solution(object):
def firstUniqChar(self, s):
s=s.lower()
sList=list(s)
numCdic={}
for c in s:
numCdic[c]=numCdic[c]+1 if c in numCdic else 1
for i in range(len(sList)):
if numCdic[sList[i]]==1:
return i
return -1
sol=Solution()
print sol.firstUniqChar('loveleetcode')