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.
collections.Counter()
collections.Counter()
+ 31 comments import collections numShoes = int(raw_input()) shoes = collections.Counter(map(int, raw_input().split())) numCust = int(raw_input()) income = 0 for i in range(numCust): size, price = map(int, raw_input().split()) if shoes[size]: income += price shoes[size] -= 1 print income
+ 3 comments without counters... coz i think there is no need to use it here
n = input() boots = map(int, raw_input().split()) orders = [map(int, raw_input().split()) for _ in range(input())] result = 0 for i in orders: if i[0] in boots: result += i[1] boots.remove(i[0]) print result
+ 6 comments from collections import Counter n = int(input()) s = Counter(map(int,input().split())) x = int(input()) total = [] for i in range(x): a,b = map(int,input().split()) if s[a] > 0: total.append(b) s.subtract(Counter([a])) else: pass print (sum(total))
+ 7 comments Here is Python 3 solution from my HackerrankPractice repository:
import collections number_of_shoes = int(input()) sizes_in_stock = collections.Counter(map(int, input().split())) total_revenue = 0 for _ in range(int(input())): size, price = map(int, input().split()) if sizes_in_stock[size]: total_revenue += price sizes_in_stock[size] -= 1 print(total_revenue)
Feel free to ask if you have any questions :)
+ 4 comments Samajh me aaye to "Copy That" XD
from collections import Counter if __name__ == '__main__': total_joote, joote_ki_variety, total_grahak = (input(), Counter(map(int, input().split())), int(input())) galle_me_kitne_pese=0 # Noto ki Barish for _ in range(total_grahak): joota_ek_number_bada_dikhao, noto_ki_to_barish_ho_rai_hai = map(int, input().split()) if joote_ki_variety[joota_ek_number_bada_dikhao] : galle_me_kitne_pese+=noto_ki_to_barish_ho_rai_hai joote_ki_variety[joota_ek_number_bada_dikhao]-=1 # Aaj Ki Kamai print(galle_me_kitne_pese)
Load more conversations
Sort 888 Discussions, By:
Please Login in order to post a comment