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.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Python
  3. Collections
  4. collections.Counter()
  5. Discussions

collections.Counter()

Problem
Submissions
Leaderboard
Discussions
Editorial

    You are viewing a single comment's thread. Return to all comments →

  • olwethuphakade89
    4 months ago+ 0 comments
    from collections import Counter
    
    shoe_total = int(input().strip())
    shoe_list = list(map(int, input().split()))
    customers = int(input())
    count_shoes = Counter(shoe_list)
    total = 0
    
    for _ in range(customers):
        shoe_size, price = list(map(int, input().split()))
        if count_shoes[shoe_size] > 0:
            count_shoes[shoe_size] -=1
            total += price
    
    print(total)
    
    0|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy