Rank of an element in a given array is calculated as no of smaller elements in that array + no of equal elements to its left. With this formula find the Rank of element 3 that appears in two locations in below array = [5,0,3,4,3];
1, 1 respectively.
first 3 located rank is 1 because only 0 is less than 3 and there are left elements which is equal to 3. second 3 rank is 2 because no of small elements are 1 and no of equal elements towards its right is is 1 (i.e 3). so total rank is 2.
Back To Top