How Many Numbers Are Smaller Than the Current Number Problem

How Many Numbers Are Smaller Than the Current Number Problem — ExecCode Easy DSA Practice

Solve the How Many Numbers Are Smaller Than the Current Number 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 the array nums, for each nums[i] find out how many numbers in the array are smaller than it. Your task is to that is, for each nums[i] you have to count the number of valid j's such that j != i and nums[j] < nums[i]. Return the answer in an array.

Examples

Input {"nums": [8, 1, 2, 2, 3]}; Output [4, 0, 1, 1, 3]. Input {"nums": [6, 5, 4, 8]}; Output [2, 1, 0, 3]

Constraints

2 <= nums.length <= 500 0 <= nums[i] <= 100

Practice How Many Numbers Are Smaller Than the Current Number free on ExecCode. Browse DSA problems, topic map, and placement guides.