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
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • 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 →

  • melarisong
    6 years ago+ 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
    
    160|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature