剑指offer python版 字符串中第一个只出现一次的字符

def aa(string):
    if not string:
        return False
    hashes={}
    for s in string:
        hashes[s]=hashes[s]+1 if hashes.get(s) else 1
    for s in string:
        if hashes[s]==1:
            return s
        
print(aa("hdahdghshaudiwaig"))
        

 

posted @ 2018-10-29 09:26  findtruth123  阅读(555)  评论(0编辑  收藏  举报