The first 50 characters appear only once

Title: The first string of characters appear only once.

def first_not_repeat(strs):
    dic = {}
    for s in strs:
        if s not in dic:
            dic[s] = 1
        else:
            dic[s] += 1
    for k,v in dic.items():
        if v==1:
            return k

  Note: traversing two strings. The first dictionary to count the number of each character appears, the second pass key value output value of 1.

Guess you like

Origin www.cnblogs.com/kingshine007/p/11494844.html