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.
from collections import Counter
list1 = []
def test(customer_shoe_size,price):
if customer_shoe_size in shoe_sizes.keys():
value = shoe_sizes.get(customer_shoe_size)
shoe_sizes.subtract([customer_shoe_size])
if value > 0:
list1.append(int(price))
def sum_():
final = list(map(int,list1))
print(sum(final))
if name == "main":
global shoe_sizes
no_of_shoes = int(input())
shoe_sizes = Counter((map(str,input().split())))
no_of_customers = int(input())
for i in range(no_of_customers):
customer_shoe_size , price = input().split()
test(customer_shoe_size,price)
sum_()
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
collections.Counter()
You are viewing a single comment's thread. Return to all comments →
from collections import Counter list1 = [] def test(customer_shoe_size,price): if customer_shoe_size in shoe_sizes.keys(): value = shoe_sizes.get(customer_shoe_size) shoe_sizes.subtract([customer_shoe_size]) if value > 0: list1.append(int(price))
def sum_(): final = list(map(int,list1)) print(sum(final))
if name == "main": global shoe_sizes no_of_shoes = int(input()) shoe_sizes = Counter((map(str,input().split()))) no_of_customers = int(input()) for i in range(no_of_customers): customer_shoe_size , price = input().split() test(customer_shoe_size,price) sum_()