【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')

上一篇:Libgdx开发ios游戏


下一篇:CoreData的使用入门到精通