Computer Science > QUESTIONS & ANSWERS > Engineering & Technology Computer Science A group of friends are playing a video game together. Du (All)
Question Answered step-by-step A group of friends are playing a video game together. During the game, each player earns a number of points. At the end of a round, players who achieve at least a cert ... ain rank get to "level up" their characters to gain increased abilities. Given the scores of the players at the end of a round, how many players will be able to level up? Note: Players with equal scores will have equal ranks, but the player with the next lower score will be ranked based on the position within the list of all players' scores. For example, if there are four players, and three players tie for first place, their ranks are 1, 1, 1, and 4. Note: No player with a score of O can level up, regardless of rank. Example n = 4 k=3 scores = [100, 50, 50, 25) These players' ranks are [1, 2, 2, 4). Because the players need to have a rank of at least 3 to level up, only the first three players qualify. Therefore, the answer is 3. Function Description Complete the function num Players in the editor below. numPlayers has the following parameters: int k: an integer denoting the cutoff rank for leveling up a player's character int scores[n]: an array of integers denoting the scores of the players Returns int the number of players who can level up after this round the players Returns: int: the number of players who can level up after this round Constraints • 15 ns 105 • Os scores[i] s 100 • ksn Input Format For Custom Testing Sample Case 0 Sample Input STDIN Function 4 5 → k = 4 scores[] size n = 5 scores = [20, 40, 60, 80, 100] 20 40 60 80 100 Sample Output 4 Explanation In order, the players achieve the ranks (5, 4, 3, 2, 1). Since the cutoff, k, is rank 24, there are 4 players who will be able to level up. 1 > import java.io.*; - 14 15 class Result { 16 17 /* 18 * Complete the 'numPlayers' function below. 19 * 20 21 22 * The function is expected to return an INTEGER. * The function accepts following parameters: 1. INTEGER K 2. INTEGER_ARRAY scores Please give me the python code and the your method. [Show More]
Last updated: 3 years ago
Preview 1 out of 3 pages
Buy this document to get the full access instantly
Instant Download Access after purchase
Buy NowInstant download
We Accept:
Can't find what you want? Try our AI powered Search
Connected school, study & course
About the document
Uploaded On
Jun 28, 2021
Number of pages
3
Written in
All
This document has been written for:
Uploaded
Jun 28, 2021
Downloads
0
Views
113
Scholarfriends.com Online Platform by Browsegrades Inc. 651N South Broad St, Middletown DE. United States.
We're available through e-mail, Twitter, Facebook, and live chat.
FAQ
Questions? Leave a message!
Copyright © Scholarfriends · High quality services·