jmpark0118 / CODING_TEST_PRACTICE

0 stars 0 forks source link

Practice>Python>Sets>No Idea! #61

Open jmpark0118 opened 4 years ago

jmpark0118 commented 4 years ago

image image

출처 : https://www.hackerrank.com/challenges/no-idea/problem

jmpark0118 commented 4 years ago

import collections

if __name__ == '__main__':
    n, m = map(int, input().split())
    my_num = list(map(int, input().split()))
    A, B = (set(map(int, input().split())) for _ in range(2))

    my_num = collections.Counter(my_num)
    a = [x if k in A else 0 for k, x in my_num.items()]
    b = [x if k in B else 0 for k, x in my_num.items()]

    print(sum(a)-sum(b))
jmpark0118 commented 4 years ago

if __name__ == '__main__':
    n, m = map(int, input().split())
    my_num = list(map(int, input().split()))
    A, B = (set(map(int, input().split())) for _ in range(2))

    plus = 0
    for i in my_num:
        if i in A:
            plus += 1
        elif i in B:
            plus -= 1

    print(plus)
jmpark0118 commented 4 years ago

list가 set보다 훨씬 더 오래 걸린다!!