admin@onlinelearningcenter.in (+91) 7 999 01 02 03

WAP To Find small adjacent of each element from given Array

Jaivik Shah
6 Posts

Given an array nums, for each nums[i] find out how many numbers in the array array are smaller than it. That is, for each num[i] you have to count the number of valid j's sunch that j != i and nums[j] < nums[i].

the answer in an array.

 

Example:

Input:

nums = [6,5,4,8]

 

 Output:

newNums = [2,1,0,3]

 

 Example 2:

Input:

nums = [7,7,7,7]

 

Output:

 

newNums = [0,0,0,0]

 

 

 

Published By : Jaivik Shah
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Comments

Jquery Comments Plugin