Array ( [0] => [1] => questions [2] => Basic [3] => Class-Student )
Dia, Sam, and Robert are the three students of a same class. You know their marks in N subjects. Your job is to find their ranks according to their score.
N, integer denoting number of subjects.
3 array of integers, denoting marks of Dia, Sam and Robert respectively in N subjects.
Print the ranks in order, seperated by space
3 23 34 23 32 53 23 55 22 67
3 2 1
5 25 35 45 55 65 66 21 41 19 29 31 44 24 10 32
1 2 3
7 25 35 45 55 65 11 29 66 21 41 19 29 77 21 31 44 24 10 32 49 64
2 1 3
Login to see Discussion
Approach:
Step-1: Calculate sum of all the scores for three students
Step-2: Add the resultant sum of all n (here n=3) students to array and sort the list in descending order
Step-3: From reversed sorted array, check the ith element with all the three members scores and increment their rank with 'i' value
Step-4: Repeat Step-3, for n times (here n is constant, i.en=3)
Note :
Let us know if you can come up with a better approach, mail us at support@theinquisitive.in Your approach will be reviewed and posted with credits to you.
Login to see Solution