jmpark0118 / CODING_TEST_PRACTICE

0 stars 0 forks source link

Practice>Python>Collections>Word Order #81

Open jmpark0118 opened 4 years ago

jmpark0118 commented 4 years ago

image image

출처 : https://www.hackerrank.com/challenges/word-order/problem

jmpark0118 commented 4 years ago

from collections import OrderedDict

if __name__ == '__main__':
    d = OrderedDict()

    for _ in range(int(input())):
        key = input()
        if key in d:
            d[key] += 1
        else:
            d[key] = 1

    distinct = len(d)
    count = [v for k, v in d.items()]
    print(distinct)
    print(*count)