CPP. : Sort Game

What is wrong in my code that I am not getting the desired output ?
My code is -https://ide.codingblocks.com/s/140897

Hello @Riankk,

  1. You are sorting array a, which is changing the order of salaries in the array.
    Solution:
    Use a pair<string,int> p; and sort it according to the p.second (i.e. salary).
    You can refer to this link for better understanding of this data structure.
    This will not affect the mapping of salary with the name.

  2. Follow the constraints properly.
    1 <= N <= 10^5

Hope, this will help.
Let me know if you still face any issue.
Give a like, if you are satisfied.

After updating , my code is still showing error as"Implicit instantiation of undefined template"
My code is:

Hello @Riankk,

  1. You have not handled the vector correctly.

  2. The logic you have applied is wrong.
    Your comparisons will fail for cases when more than 2 employees have the same salary.
    I have corrected the syntax of your code:
    https://ide.codingblocks.com/s/141018

Please, refer to the following code for correct logic and let me know if you face any issue:

Hope, this would help.
Give a like, if you are satisfied.

1 Like

I understood the concept. Thank You So Much !!!:grinning:

Anytime @Riankk,

Please, mark this doubt as resolved.