标签:ret sel 遍历 stun HERE 出现 code rac 字符
遍历的话若全部遍历则为N,若遍历k次,则为k
class Solution:
"""
@param str: str: the given string
@return: char: the first unique character in a given string
"""
def firstUniqChar(self, str):
# Write your code here
for i in str:
b = str.count(i) # 时间复杂度太大了
if b == 1:
return i
# 遍历不从前遍历,可以减少遍历次数
标签:ret sel 遍历 stun HERE 出现 code rac 字符
原文地址:https://www.cnblogs.com/wkhzwmr/p/15038296.html