FastPrepOrganization Reputation After Employee Departures
Problems/Organization Reputation After Employee Departures

Organization Reputation After Employee Departures

HSBC logoHSBC● MediumINTERNOA
QuestionFunctionExamplesConstraints

Problem statement

Source note: The visible screenshot is cropped before the complete query format and leaves the fewer-than-k teammate rule unclear. The judged core task matches the visible source at about 70%.

An organization has n employees with IDs from 1 through n. Employee i has efficiency efficiency[i - 1] and belongs to team teamId[i - 1]. The organization's reputation is the sum of the efficiencies of all employees who are still active.

Process the rows of queries in order. A row [employeeId, k] describes one day:

  1. Fire the currently active employee with ID employeeId.
  2. From that employee's team, up to k other active employees resign. Choose employees by lower efficiency first; when efficiencies are equal, choose the lower employee ID first.
  3. If fewer than k active teammates remain, all of them resign.

Return an array containing the organization's reputation at the end of each day.

Every queried employeeId is active at the start of its day. Once an employee is fired or resigns, that employee never returns.

Function

getOrganizationReputation(efficiency: int[], teamId: int[], queries: int[][]) → long[]

Examples

Example 1

efficiency = [10,5,8,3]teamId = [1,1,2,1]queries = [[1,1],[3,0]]return = [13,5]

The initial reputation is 26. On the first day, employee 1 is fired and employee 4, the least-efficient remaining member of team 1, resigns. The reputation becomes 13. On the second day, employee 3 is fired and no teammate is requested, so the reputation becomes 5.

Example 2

efficiency = [4,4,7,1,9]teamId = [2,2,2,3,3]queries = [[2,2],[5,3]]return = [10,0]

After employee 2 is fired, the two remaining members of team 2 resign, leaving reputation 10. On the next day, employee 5 is fired. Team 3 has only employee 4 remaining, so that employee also resigns and the final reputation is 0.

Example 3

efficiency = [7]teamId = [9]queries = [[1,5]]return = [0]

The only employee is fired. No teammate remains, so the reputation is 0 even though k is larger than the team.

Constraints

  • 1 <= efficiency.length = teamId.length <= 2 * 10^5
  • -10^9 <= efficiency[i] <= 10^9
  • 1 <= teamId[i] <= 10^9
  • 1 <= queries.length <= efficiency.length
  • Every row of queries contains exactly two integers [employeeId, k].
  • Each queried employeeId is active at the start of its day.
  • 0 <= k <= efficiency.length
  • Reputation calculations use signed 64-bit integers.

More HSBC problems

  • Minimum Deletion Cost for Distinct Adjacent CharactersOA · Seen Oct 2026
  • Maximum 69 NumberONSITE INTERVIEW · Seen Oct 2026
  • Second Distinct Largest ElementONSITE INTERVIEW · Seen Oct 2026
All HSBC interview questionsSee HSBC hiring insights
Saved
class Solution {
    public long[] getOrganizationReputation(int[] efficiency, int[] teamId, int[][] queries) {
        // Write your code here.
    }

}
Checking account…