An arcade game player wants to climb to the top of the leaderboard and track their ranking. The game uses Dense Ranking, so its leaderboard works like this: The player with the highest score is ranked number  on the leaderboard. Players who have equal scores receive the same ranking number, and the next player(s) receive the immediately following ranking number. Example   The ranked players will have ranks , , , and , respectively. If the player's scores are ,  and , their rankings after each game are ,  and . Return . Function Description Complete the climbingLeaderboard function in the editor below. climbingLeaderboard has the following parameter(s): int ranked[n]: the leaderboard scores int player[m]: the player's scores Returns int[m]: the player's rank after each new score Input Format The first line contains an integer , the number of players on the leaderboard. The next line contains  space-separated integers , the leaderboard scores in decreasing order. The next line contains an integer, , the number games the player plays. The last line contains  space-separated integers , the game scores. Constraints      for   for  The existing leaderboard, , is in descending order. The player's scores, , are in ascending order. Subtask For  of the maximum score:     Sample Input 1 CopyDownload Array: ranked1001005040402010 Array: player52550120 7 100 100 50 40 40 20 10 4 5 25 50 120 Sample Output 1 6 4 2 1 Explanation 1   Alice starts playing with  players already on the leaderboard, which looks like this:   After Alice finishes game , her score is  and her ranking is :   After Alice finishes game , her score is  and her ranking is :   After Alice finishes game , her score is  and her ranking is tied with Caroline at :   After Alice finishes game , her score is  and her ranking is :     Sample Input 2 CopyDownload Array: ranked1009090807560 Array: player50657790102 6 100 90 90 80 75 60 5 50 65 77 90 102 Sample Output 2 6 5 4 2 1

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

An arcade game player wants to climb to the top of the leaderboard and track their ranking. The game uses Dense Ranking, so its leaderboard works like this:

  • The player with the highest score is ranked number  on the leaderboard.
  • Players who have equal scores receive the same ranking number, and the next player(s) receive the immediately following ranking number.

Example

 

The ranked players will have ranks , , , and , respectively. If the player's scores are ,  and , their rankings after each game are ,  and . Return .

Function Description

Complete the climbingLeaderboard function in the editor below.

climbingLeaderboard has the following parameter(s):

  • int ranked[n]: the leaderboard scores
  • int player[m]: the player's scores

Returns

  • int[m]: the player's rank after each new score

Input Format

The first line contains an integer , the number of players on the leaderboard.
The next line contains  space-separated integers , the leaderboard scores in decreasing order.
The next line contains an integer, , the number games the player plays.
The last line contains  space-separated integers , the game scores.

Constraints

  •  
  •  
  •  for 
  •  for 
  • The existing leaderboard, , is in descending order.
  • The player's scores, , are in ascending order.

Subtask

For  of the maximum score:

  •  
  •  

Sample Input 1

CopyDownload
Array: ranked1001005040402010 Array: player52550120
7
100 100 50 40 40 20 10
4
5 25 50 120

Sample Output 1

6
4
2
1

Explanation 1

 

Alice starts playing with  players already on the leaderboard, which looks like this:

 

After Alice finishes game , her score is  and her ranking is :

 

After Alice finishes game , her score is  and her ranking is :

 

After Alice finishes game , her score is  and her ranking is tied with Caroline at :

 

After Alice finishes game , her score is  and her ranking is :

 

 

Sample Input 2

CopyDownload
Array: ranked1009090807560 Array: player50657790102
6
100 90 90 80 75 60
5
50 65 77 90 102

Sample Output 2

6
5
4
2
1
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Stack
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY