Testcases are incorrect or runtime


I followed exactly what was being asked in question, and sample input also gave correct output then why all testcases are incorrect?? Please point out the errors in my code and also provide any other approach that i can follow.

hey @ankush.bhardwaj0, your function for sorting is of very high complexity thatswhy it gives runtime error for high inputs.

You can use sort function for this, but sorting according salary in compare function will be very difficult. Thatswhy you need to a datatype that will combine both name and salary at same index. And for that we have pair datatype.
Here is the efficient approach using pair datatype.

refer to this code and if you face any problem.Feel free to contact

@Gaurav13998 Since i am going through the course serially, I have not been introduced to these concepts. Will this concept be taught later on in the course?

hey @ankush.bhardwaj0, I don’t have access to your code. So I don’t know whether pair is specially taught or not. Surely it will be used ahead in your question.
But if you are totally unfamiliar with pair datatype. Just go through this video once. https://youtu.be/4Gs-urq8UwE

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.