Skip to content

TheQueryCrew/P11-SmallerNumbers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Smaller Numbers In An Array

Write a Program to Count Smaller Numbers

Count Smaller Numbers:

You are given an integer array and you have to return a new count array. The counts array has the property where count[i] is the number of smaller elements to the right of nums[i].

Input:

Enter Number of array elements: 4
Enter array elements: [6,2,5,8]

Output:

New Array: [2,0,0,0]

Explanation:

As 6 Has 2 Smaller Numbers To The Right Of Its Position, In The New Array The Output Will Be 2.
As 2 Has 0 Smaller Numbers To The Right Of Its Position, In The New Array The Output Will Be 0.
As 5 Has 0 Smaller Numbers To The Right Of Its Position, In The New Array The Output Will Be 0.
As 8 Has 0 Smaller Numbers To The Right Of Its Position, In The New Array The Output Will Be 0.