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. Algorithms
  3. Implementation
  4. Climbing the Leaderboard
  5. Discussions

Climbing the Leaderboard

Problem
Submissions
Leaderboard
Discussions
Editorial

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

  • albiewalbie
    5 years ago+ 22 comments

    Python 2

    n = int(raw_input().strip())
    scores = map(int,raw_input().strip().split(' '))
    m = int(raw_input().strip())
    alice = map(int,raw_input().strip().split(' '))
    
    leaderboard = sorted(set(scores), reverse = True)
    l = len(leaderboard)
    
    for a in alice:
        while (l > 0) and (a >= leaderboard[l-1]):
            l -= 1
        print l+1
    
    82|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature