Skip to content

Practice Count of Smaller Numbers After Self

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#315
LeetCode Problem

Count of Smaller Numbers After Self

Problem Statement

Given an integer array nums, return an integer array counts where counts[i] is the number of smaller elements to the right of nums[i].

Source: Count of Smaller Numbers After Self on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [5,2,6,1]
Output
[2,1,1,0]

# Example 2

Input
nums = [-1]
Output
[0]

# Example 3

Input
nums = [-1,-1]
Output
[0,0]

Constraints

1 <= nums.length <= 10^5
-10^4 <= nums[i] <= 10^4

Related LeetCode Problems

Practice more problems similar to Count of Smaller Numbers After Self.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.