Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
753 B
6
Indexable
Never
def processLogs(logs, threshold):

    trans = []
    freq = {}
    res = []

    for log in logs:
        trans.append(log.split())


    for t in trans:
        if(t[0]==t[1]):
            if(t[0] not in freq):
                freq[t[0]] = 1
            else:
                freq[t[0]] += 1

        else:
            if(t[0] not in freq):
                freq[t[0]] = 1
            else:
                freq[t[0]] += 1

            if(t[1] not in freq):
                freq[t[1]] = 1
            else:
                freq[t[1]] += 1


    for key in freq:
        print(key,freq[key])
        if(freq[key]>=threshold):
            res.append(int(key))

    res_str = []

    for r in res:
        res_str.append(str(r))

    return list(res_str)