Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
675 B
2
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))


    return res