← Amazon Interview Insights

Amazon·Software Engineer·Online Assessment (OA)·Senior

Senior
Apr 2026

Summary

Amazon SWE online assessment, looks like a coding problem set for a mid-to-senior level position. The main question was a simulation/probability problem about bots competing in rounds until one task survives. Post hints this is worth paying attention to if you're going for a higher level role.

Questions Asked (1)

Q1

Given n inventory tasks each with a certain number of bots, tasks compete in rounds where two are picked at random, the one with more bots wins and absorbs the loser's bots (ties broken randomly). Which tasks have at least one possible sequence of outcomes where they end up as the last surviving task? Return the 1-based indices in ascending order.

Algorithms & Data Structures
Author's notes

The key insight I kept circling around was: a task can only be eliminated by one with strictly more bots, so any task that isn't strictly dominated by another has a shot.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the process as a tournament where a task can win if its bot count is at least the maximum of all other tasks, or if it can absorb smaller tasks to eventually exceed the maximum. Sort tasks by bot count and check if the cumulative sum of smaller tasks plus the current task's bots is at least the next larger task's bots, iterating from smallest to largest. Tasks that can reach the maximum bot count through such absorption are possible winners.

Pro tip: Clarify that ties are broken randomly, so a task with equal bots to the current maximum can also win if it gets favorable tie-breaks; this often trips candidates who assume strict inequality.

1. Understand the winning condition

A task can be the last survivor if there exists a sequence of merges where it eventually absorbs all others. This requires that at some point, it can become the largest by absorbing smaller tasks.

2. Sort tasks by bot count

Sort the tasks in ascending order of bots. This helps in analyzing which tasks can be absorbed to build up strength.

3. Compute prefix sums and check reachability

Iterate through sorted tasks, maintaining the cumulative sum of bots of tasks that can be absorbed. A task can be a possible winner if its bots plus the sum of all smaller tasks is at least the bots of the next larger task, allowing it to eventually absorb all larger tasks.

4. Identify all possible winners

Any task that can reach the maximum bot count through absorption (including ties) is a possible winner. Collect their original 1-based indices and return them in ascending order.

Key Points to Mention

  • Sorting tasks by bot count to simplify the absorption process.
  • Using prefix sums to track the total bots a task can accumulate from smaller tasks.
  • The condition for a task to be a possible winner: its bots plus sum of all smaller tasks >= bots of the next larger task.
  • Handling ties: tasks with equal bots can also win due to random tie-breaking.
  • Time complexity: O(n log n) due to sorting, which is efficient for large n.
  • Edge cases: all tasks have equal bots, or one task has significantly more bots than others.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.