我的个人微信公众号:Microstrong
微信公众号ID:MicrostrongAI
微信公众号介绍:Microstrong(小强)同学主要研究机器学习、深度学习、计算机视觉、智能对话系统相关内容,分享在学习过程中的读书笔记!期待您的关注,欢迎一起学习交流进步!
知乎主页:https://www.zhihu.com/people/MicrostrongAI/activities
题目链接:
题目描述:
解题思路:
(1)时间复杂度
已经AC的代码:
# -*- coding:utf-8 -*-
class Solution:
def FirstNotRepeatingChar(self, s):
# write code here
if s is None or len(s) == 0:
return -1
for i in range(len(s)):
num = s.count(s[i])
if num == 1:
return s.index(s[i])
elif i >= len(s):
return -1