Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Rank vs Dense_Rank
00:00
5 left

Rank vs Dense_Rank

MediumPython

Problem

What is the difference between RANK and DENSE_RANK?

Asked in the Conceptual questions stage. Implement both ranking rules for a list of integer scores, ordered from highest to lowest.

Input and Output

Given scores, return a dictionary with rank and dense_rank arrays. Equal scores receive equal positions. RANK leaves gaps after ties, while DENSE_RANK does not.

Constraints

  • 1 <= len(scores) <= 10^5
  • Scores are integers from -10^9 through 10^9

Function Signature

def rank_scores(scores):
Interviewer

Your question is Rank vs Dense_Rank. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.