My code satisfies the sample case but I am getting WA for all test cases. Kindly help.
Sort Game Code- WA in Test Cases
I think you did not get the question properly.
you need to sort first on basis of salary, and if salary is equal, tie will be broken using name.
problems in your code:
- you did not sort based on salary.
- when salaries are equal, you can not just compare consecutively names to sort on basis of name.
for eg. mat 1000
rat 1000
cat 1000
now salaries are equal, and if i compare consecutively, i will get sorted output as
mat, cat, rat with salaries. but solution is cat, mat, rat.
hint for solution: read about comparator
thanks
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.