A choropleth map colors regions by rank instead of raw value, so a few huge outliers don't wash out the colors. The region values are in values.
Write colorLevels(values) that replaces each value with its level: the smallest distinct value gets level 1, the next distinct value level 2, and so on. Equal values get the same level.
Input: values = [40,10,40,25] Output: [3,1,3,2]
The distinct values in order are 10, 25, 40, so they get levels 1, 2, 3.
Input: values = [] Output: []
No regions, no levels.
0 <= values.length <= 10^5-10^9 <= values[i] <= 10^9Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #93 Rank Values for a Color Scale. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.