Skip to content

Commit 9ae794e

Browse files
authored
Create climbingLeaderboard.py
1 parent 5c4cf91 commit 9ae794e

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Diff for: climbingLeaderboard.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/python3
2+
3+
import math
4+
import os
5+
import random
6+
import re
7+
import sys
8+
9+
# Complete the climbingLeaderboard function below.
10+
def climbingLeaderboard(scores, alice):
11+
scores = sorted(list(set(scores)))
12+
index = 0
13+
rank = []
14+
n = len(scores)
15+
for i in alice:
16+
while (n > index and i >= scores[index]):
17+
index += 1
18+
rank.append(n + 1 - index)
19+
return rank
20+
21+
if __name__ == '__main__':
22+
fptr = open(os.environ['OUTPUT_PATH'], 'w')
23+
24+
scores_count = int(input())
25+
26+
scores = list(map(int, input().rstrip().split()))
27+
28+
alice_count = int(input())
29+
30+
alice = list(map(int, input().rstrip().split()))
31+
32+
result = climbingLeaderboard(scores, alice)
33+
34+
fptr.write('\n'.join(map(str, result)))
35+
fptr.write('\n')
36+
37+
fptr.close()

0 commit comments

Comments
 (0)