Google | Onsite | Count of Larger Numbers Before Self
6481

Position: Softwre Engineer, Tools and Infrastracture

Given an integer array nums. All elements are in range [1-n]. Return a new array counts where counts[i] is the number of larger elements to the left of nums[i].

Example:

Input: [4, 2, 1, 3, 5]
Output: [0, 1, 2, 1, 0]

Follow-up:
Given an array counts, return the original array.

Comments (23)