Employee Ratings Management System
Reported by candidates from Amazon's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Amazon reported this one in September 2026, and it looks like a design problem but it's really an order-statistics problem in disguise. You append ratings, delete by current index, and ask for the max with its earliest index. Deletions shift everything left, so the naive list blows up at 100000 operations. If you have the OA in a day or two, this is the pattern to recognize. StealthCoder sits invisibly on your screen as a safety net if you blank on the data structure mid-assessment.
The problem
Process a sequence of operations on an initially empty ordered list of employee ratings. Operation [1, rating] appends a rating. Operation [2, index] deletes the rating at the current zero-based index, shifting later indices left. Operation [3] queries the maximum rating and its earliest current index. Return one row [maximumRating, earliestIndex] for every query operation. Every deletion index is valid, and every query occurs while at least one rating exists. Function employeeRatings(operations: int[][]) → int[][] Examples Example 1 operations = [[1,5],[1,7],[1,7],[3],[2,1],[3]] return = [[7,1],[7,1]] The first maximum is at index 1; after deleting it, the remaining 7 shifts to index 1. Example 2 operations = [[1,-2],[3],[1,4],[3]] return = [[-2,0],[4,1]] Queries reflect both negative and later positive ratings. Example 3 operations = [[1,3],[1,1],[2,0],[3]] return = [[1,0]] Deleting index zero shifts the remaining rating to zero. Constraints 1 ≤ operations.length ≤ 100000. Each operation is exactly one of [1, rating], [2, index], or [3]. -10^9 ≤ rating ≤ 10^9. Deletion indices and non-empty query preconditions are valid.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick: indices shift on delete, so you can't store raw positions. Keep every appended rating in a fixed slot (its append order) and use a Fenwick tree or segment tree over those slots, marking alive or dead. The current index of a slot is the count of alive slots before it. To delete at index k, find the k-th alive slot with a tree descent. For the max query, use a segment tree storing (max rating, leftmost slot) over alive slots, then convert that slot to its current index with a prefix count. Ties go to the leftmost slot. The pitfall is using list.pop(index) and max(), which is O(n) per op and times out. Another is forgetting that dead slots must be reset to negative infinity in the max tree. If you blank in the live OA, StealthCoder can feed you the segment tree skeleton.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Employee Ratings Management System 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. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Amazon's OA.
Amazon reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Employee Ratings Management System FAQ
How hard is the Amazon Employee Ratings Management System problem really?+
Medium-hard. The logic is simple, but the constraint of 100000 operations kills brute force. You need a segment tree or Fenwick tree, and most candidates lose time on the shifting index part, not on the max query.
What's the core trick?+
Never store current indices. Give each appended rating a permanent slot, track alive or dead, and compute the current index as the number of alive slots before it. Deletion by index becomes finding the k-th alive slot.
Can I just use a list and max()?+
It passes the examples but costs O(n) per delete and per query. With 100000 operations that's up to billions of steps in the worst case. Expect timeouts on the hidden tests, so build the tree version.
How do I handle ties for the maximum?+
Return the earliest current index. In the segment tree merge, when the left and right maxima are equal, keep the left one. Then convert that slot to its current index using a prefix count of alive slots.
How do I prepare for this in 48 hours?+
Write a segment tree with point update and max query, then a Fenwick tree with k-th element search. Practice combining them on a small version of this problem. Test with deletions at index 0 and repeated maxima.