We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Since the array might contain duplicate elements, we need to count them. The result is a dictionary with elements as keys and their counts as values:
counter = Counter(arr)
Since "For each i integer in the array, if i in A, you add 1 to your happiness" to get total amount of happiness, sum the number of occurrences of A elements in the array:
No Idea!
You are viewing a single comment's thread. Return to all comments →
Since the array might contain duplicate elements, we need to count them. The result is a dictionary with elements as keys and their counts as values:
Since "For each i integer in the array, if i in A, you add 1 to your happiness" to get total amount of happiness, sum the number of occurrences of A elements in the array:
itemgeter is needed to get multiple values from dictionary: https://stackoverflow.com/a/24204498/5106051
Then do the same for the amount of sadness and combine it with the amount of happiness.