题目描述
在一个字符串(0<=字符串长度<=10000,全部由字母组成)中找到第一个只出现一次的字符,并返回它的位置, 如果没有则返回 -1(需要区分大小写).
# -*- coding:utf-8 -*-
class Solution:
def FirstNotRepeatingChar(self, s):
# write code here
count = 0
for x in s:
if (s.count(x)==1):
return count
count+=1
return -1
补充:
A-Z对应的ASCII码为65-90,a-z对应的ASCII码值为97-122,