collections.Counter() HackerRank

 from collections import Counter


no_of_shoes = int(input())
shoe_size_avaialble = list(map(int,input().split()))
available_shoes = Counter(shoe_size_avaialble)
customers = int(input())
totalprice =0

for i in range (customers):
    size,price=list(map(int,input().split()))
    if available_shoes[size]:
        totalprice=totalprice+price
        available_shoes[size] -=1
print(totalprice)

Comments

Popular posts from this blog

Mean, Var, and Std in numpy HackerRank

Min and Max in numpy HackerRank

Collections.deque() HackersRank Solution