Wrong anser at test case 14/20

  • 0

    My output gave three items of a department but it expects 4 items of a department.

    Open the image in a new tab plz.

    enter image description here

    {"headers": {"Employee": ["Id", "Name", "Salary", "DepartmentId"], "Department": ["Id", "Name"]}, "rows": {"Employee": [[1, "Joe", 60000, 1], [2, "Ralph", 50000, 1], [3, "Joel", 60000, 1], [4, "Tracy", 75000, 1]], "Department": [[1, "IT"]]}}

    {"headers": ["Department", "Employee", "Salary"], "values": [["IT", "Tracy", 75000], ["IT", "Joe", 60000], ["IT", "Joel", 60000]]}

    {"headers": ["Department", "Employee", "Salary"], "values": [["IT", "Tracy", 75000], ["IT", "Joe", 60000], ["IT", "Joel", 60000], ["IT", "Ralph", 50000]]}

  • 0

    The question is asking for employees who earn the top three salaries, and in this case there are two employees Joe and Joel who are earning the second highest salary, which is 60,000.

  • 0

    I agree with the OP. If there was a tie for third then having more than 3 entries would make sense. However, if there is a tie for the second highest salary and then a fourth highest salary is lower, then the 4th one should be excluded.

  • 0

    Salaries and people have different rankings. Think about this: if I ask you to pick the 3 biggest numbers from [1,2,3,4,3,2,1] what would be your answer? Now, if I ask you to pick all the indices where these 3 biggest numbers are located? Just because there are two 2s, you'll still include all 5 indices. The problem description is clearly asking for "employees who earn the top three salaries", i.e. indices in my example.

  • 0

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.