タイトル説明
1つの文字列(0 <=文字列<= 10000、アルファベットのすべての長さ)最初の文字を見つけることが一度だけ表示され、その位置に戻る、または-1でない場合(大文字と小文字を区別)で。
用例:
入力:
Googleは
、対応する出力は次のようになります。
4
コード
# -*- 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)