HackerRank Python- No Idea
There is an array of n integers. There are also 2 disjoint sets, A and B, each containing m integers. You like all the integers in set A and dislike all the integers in set B. Your initial happiness is 0.
- # Enter your code here. Read input from STDIN. Print output to STDOUT
-
- if __name__ == "__main__":
- happiness = 0
- n, m = map(int, input().strip().split(' '))
- arr = list(map(int, input().strip().split(' ')))
-
- good = set(map(int, input().strip().split(' ')))
- bad = set(map(int, input().strip().split(' ')))
-
- for el in arr:
- if el in good:
- happiness += 1
- elif el in bad:
- happiness -= 1
-
- print(happiness)