Page 1 of 1

Given the array nums, for each nums[i] find out how many numbers in the array are smaller than it. That is, for each num

Posted: Thu Jun 02, 2022 8:16 am
by answerhappygod
Given The Array Nums For Each Nums I Find Out How Many Numbers In The Array Are Smaller Than It That Is For Each Num 1
Given The Array Nums For Each Nums I Find Out How Many Numbers In The Array Are Smaller Than It That Is For Each Num 1 (237 KiB) Viewed 17 times
Need the code in C.
Given the array nums, for each nums find out how many numbers in the array are smaller than it. That is, for each nums you have to count the number of valid j's such that j !=i and nums [j] < nums. Return the answer in an array. Example 1: Input: 5 81223 Where: 5 is the number of elements in the array. Output: 40113 Explanation: For nums[0]=8 there exist four smaller numbers than it (1 2 2 and 3). For nums[1]=1 does not exist any smaller number than it. For nums[2]=2 there exist one smaller number than it (1). For nums[3]=2 there exist one smaller number than it (1). For nums[4]=3 there exist three smaller numbers than it (1 2 and 2). Example 2: Input: 4 6548 Output: 2103 Example 3: Input: 4 7777 Output: 0000 Constraints: • 2 <= nums <= 500 • 0 <= nums <= 100