Product of Array Except Self
Reported by candidates from Amazon's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The Amazon OA reported in September 2026 is Product of Array Except Self, and the trap is zeros. Most people reach for total product divided by nums[i], then watch it blow up the second a 0 shows up. Division is banned here anyway, and the O(n) requirement rules out the brute force double loop. This is an array problem with a prefix and suffix trick, and it's short once you see it. If you blank in the live assessment, StealthCoder runs invisibly on your desktop and gives you the solution in real time, so one bad minute doesn't sink the attempt.
The problem
Given an integer array nums, return an array answer where answer[i] equals the product of every element of nums except nums[i]. Solve the problem without division in O(n) time. The output array does not count as extra space. Function productExceptSelf(nums: int[]) → int[] Examples Example 1 nums = [1,2,3,4] return = [24,12,8,6] For index 0, the product is 2 * 3 * 4 = 24; apply the same rule at every index. Example 2 nums = [-1,1,0,-3,3] return = [0,0,9,0,0] Only the position containing zero has a nonzero result, equal to (-1) * 1 * (-3) * 3 = 9. Example 3 nums = [2,3] return = [3,2] With two values, each output is the other value. Constraints 2 <= nums.length <= 10^5. -30 <= nums[i] <= 30. Every prefix product and suffix product fits in a signed 32-bit integer.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick: answer[i] is the product of everything left of i times everything right of i. Do two passes. First pass, fill answer[i] with the running prefix product, starting at 1. Second pass, walk right to left with a running suffix variable starting at 1, multiply it into answer[i], then multiply the suffix by nums[i]. That's O(n) time and O(1) extra space, since the output array doesn't count. Zeros handle themselves. Example 2, [-1,1,0,-3,3], returns [0,0,9,0,0] with no special casing. The common pitfall is trying the divide-by-total approach and patching zeros with counts, which is messy and disallowed. Another is updating the suffix before using it, which shifts everything by one. Keep the order: multiply, then update. StealthCoder is your hedge in the live OA if the two-pass idea slips your mind under pressure.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Product of Array Except Self 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 StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as product of array except self. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Amazon's OA.
Amazon 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.
Product of Array Except Self FAQ
How hard is Product of Array Except Self really?+
Medium. The code is about ten lines. The difficulty is seeing that prefix and suffix products replace division. Once you've seen it, it's easy to rewrite from memory. Amazon reported it in September 2026, so expect it as a straight array question.
What's the trick to avoid division?+
Build a left-product array in one pass, then sweep right to left with a running suffix product and multiply it into the same output array. Each index ends up with left product times right product, which is everything except itself.
How do zeros affect the solution?+
They don't, if you use prefix and suffix products. The zero's own index gets the product of the others, and every other index picks up the zero in its prefix or suffix, so it becomes 0. Example 2 shows exactly this.
How do I get O(1) extra space?+
Use the output array to store prefix products first. Then keep a single integer for the running suffix product and fold it in during the backward pass. The problem says the output array isn't counted as extra space.
How do I prepare in 48 hours?+
Write this solution from scratch twice, then test it on [2,3], on an array with one zero, and on an array with two zeros. Then do a few other prefix-sum style array problems so the pattern feels automatic.