Competitive Gaming Ranks
Updated
Problem statement
A player’s competition rank is 1 + the number of players with a strictly greater score. Tied players share a rank, and the next rank skips the tied positions. Scores [100,100,100,90] therefore have ranks [1,1,1,4].
Count players whose rank is at most k and whose score is positive. A zero-score player never levels up, regardless of rank. For this exercise, assume k = 0 admits no players. Do not change the input.
Function
numPlayers(k: int, scores: int[]) → intExamples
Example 1
k = 3scores = [100,50,50,25]return = 3The ranks are 1, 2, 2, 4, so the first three players qualify.
Example 2
k = 2scores = [100,100,100,90]return = 3All three top players have rank 1, even though more than k players qualify.
Example 3
k = 3scores = [0,0,0]return = 0Zero-score players cannot level up.
Constraints
1 <= scores.length <= 100000.0 <= scores[i] <= 100.0 <= k <= scores.length.
More Roblox Online Assessment questions
- Centered Block Placement QueriesOA · Seen Oct 2026
- Robot Navigation Around LasersOA · Seen Oct 2026
- Factory Batch Profit (Game Adaptation)OA · Seen Sep 2026
- Nested Recipe Blocks (Game Adaptation)OA · Seen Sep 2026
- Vehicle Builds for Required Terrain (Game Adaptation)OA · Seen Sep 2026
- Track Received Byte RangesOA · Seen Sep 2026
- Break a PalindromeOA · Seen Jun 2026
- Count Pairs Differing in One DigitOA · Seen Oct 2025
- Find Zero Cells in a 2×2 GridOA · Seen Oct 2025
- Cat Route Budget Planning (Game Adaptation)OA · Seen Aug 2025
Similar questions at other companies
- Count User Mentions in Chat MessagesRamp · OARamp interview questions
- Word Frequency Counts in Alphabetical OrderAbridge · OAAbridge interview questions
- Minimum Magic Stones After MergesElevenLabs · OAElevenLabs interview questions
- Items SortAkuna Capital · OAAkuna Capital interview questions
- Count Cross-Array Target-Sum PairsVisa · OAVisa interview questions
- Array Rank TransformTata Consultancy Services · OATata Consultancy Services interview questions
- Find Max Health SumAmazon · OA
- Influencers SquadTikTok · OATikTok interview questions
- Count Teams Outscoring a Target TeamBloomberg LP · OABloomberg LP interview questions
- Count Soldiers with a Next-Rank SuperiorMarshall Wace · OAMarshall Wace interview questions