#-*- 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')
相关文章
- 03-13【leetcode❤python】387. First Unique Character in a String
- 03-13【LeetCode】387. First Unique Character in a String 解题报告(Python)
- 03-13First Unique Character in a String 的变种问题返回第一个找到符合条件的字符
- 03-13LeetCode之First Unique Character in a String
- 03-13【LeetCode】387. First Unique Character in a String
- 03-13[LeetCode] First Unique Character in a String 字符串第一个不同字符
- 03-13First Unique Character in a String (找到一个字符串中第一个不重复的字符)
- 03-13LeetCode 387: 字符串中的第一个唯一字符 First Unique Character in a String