Title Description
In one string (0 <= length of the string <= 10000, all of the alphabet) find a first character appears only once, and returns to its position, or -1 if not (case-sensitive).
example:
Input:
the corresponding output would be:
4
Code
# -*- coding:utf-8 -*-
class Solution:
def FirstNotRepeatingChar(self, s):
# write code here
if s == '':
return -1
else:
a = list(s)
res = []
for i in a:
count = 0
for j in a:
if i == j:
count +=1
res.append(count)
return res.index(1)