LeetCode 178: Rank Scores

Database

Problem Description

Explanation

To rank the scores according to the rules provided, we can use the following steps:

  1. Create a temporary table that includes the unique scores and their counts in descending order.
  2. Use a variable to keep track of the current rank.
  3. Iterate through the temporary table and assign the rank to each score based on the previous count.
  4. Return the result table ordered by score in descending order.

Time complexity: O(nlogn) - sorting the scores table Space complexity: O(n) - storing the unique scores and counts

Solutions

# Write your Java solution here

Loading editor...