Reported August 2026
HSBChash table

Organization Reputation After Employee Departures

Reported by candidates from HSBC's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live HSBC OA. Under 2s to a working solution.
Founder's read

The HSBC OA reported in August 2026 looks like a simulation problem, but it's really a data structure question. You've got employees grouped by team, a firing step, then a "remove the k weakest teammates" step, and 2*10^5 employees means brute force dies. If you spot the structure early, the code is short. If you don't, you burn the whole assessment on a TLE. StealthCoder sits invisibly as a safety net on the live OA if your mind goes blank on the setup, but the idea below is all you need to walk in ready.

The problem

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:
Fire the currently active employee with ID employeeId.
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.
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.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Group employees by teamId, then sort each group by (efficiency, employeeId). That ordering is exactly the resignation order, so each team becomes a sorted list with a pointer to the next weakest candidate. Keep a running reputation total as a 64-bit sum and an active flag per employee. On each query, mark the fired employee inactive and subtract their efficiency. Then advance that team's pointer, skipping anyone already inactive, and remove up to k active members, subtracting each. Every employee is passed over at most once across all queries, so total work is O(n log n) for sorting plus O(n + q) for processing. The pitfall is forgetting to skip already-fired employees, or letting the fired person count toward k. Also watch negative efficiencies and use long for the sum. If you freeze on the live OA, StealthCoder is the hedge, but this pointer approach is the whole trick.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Organization Reputation After Employee Departures cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass HSBC's OA.

HSBC reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Organization Reputation After Employee Departures FAQ

What's the trick in the HSBC Organization Reputation problem?+

Sort each team's employees by efficiency, then ID, once. That order is the resignation order. Keep a pointer per team and skip inactive employees as you advance. Each employee gets passed at most once, so the whole thing is near linear after sorting.

Do I need a heap or a TreeSet?+

No. Nothing gets inserted after setup, only removed. A pre-sorted list per team plus a moving pointer and an active array does the same job with less code and no log factor per removal.

What are the common bugs on this one?+

Counting the fired employee toward k, forgetting to skip teammates who were already fired in an earlier day, and overflowing with int sums. Negative efficiencies are allowed, so reputation can go down or up when someone leaves. Use 64-bit.

What complexity should I aim for with n up to 2*10^5?+

O(n log n) overall. Sorting dominates. Query processing is amortized O(n + q) because each pointer only moves forward. Anything that rescans a team on every query risks timing out when one team holds most employees.

How do I prepare for this in 48 hours?+

Practice grouping by key with a hash map, sorting groups with a tuple comparator, and amortized pointer sweeps. Then hand-trace Example 2 where k exceeds the remaining teammates. If you can explain why each employee is touched once, you're ready.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with HSBC.

OA at HSBC?
Invisible during screen share
Get it