Rank Transform of an Array Problem

Rank Transform of an Array Problem — ExecCode Easy DSA Practice

Solve the Rank Transform of an Array problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given an array of integers arr, replace each element with its rank. Your task is to the rank represents how large the element is. The rank has the following rules: - Rank is an integer starting from 1. - The larger the element, the larger the rank. Return the required answer exactly as shown in the examples.

Examples

Input {"arr": [40, 10, 20, 30]}; Output [4, 1, 2, 3]. Input {"arr": [100, 100, 100]}; Output [1, 1, 1]

Constraints

0 <= arr.length <= 10^5 -10^9 <= arr[i] <= 10^9

Practice Rank Transform of an Array free on ExecCode. Browse DSA problems, topic map, and placement guides.