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.
fromcollectionsimportCounter'''# method 1 without Counter:deftotal_money_earned(N,shoes_sizes):total=0shoe_size_price=[]for_inrange(N):shoe_size_price=list(map(int,input().split()))ifshoe_size_price[0]inshoe_sizes:total+=shoe_size_price[1]shoe_sizes.remove(shoe_size_price[0])shoe_size_price.clear()returntotal'''# method 2 with Counter:deftotal_money_earned(N,shoes_sizes):total=0shoes=Counter(shoes_sizes)shoe_size_price=[]for_inrange(N):size,price=map(int,input().split())ifshoes[size]:total+=priceshoes[size]-=1returntotalif__name__=="__main__":X=int(input())shoe_sizes=list(map(int,input().split()))N=int(input())print(total_money_earned(N,shoe_sizes))
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 →