Reported September 2026
Capgeminiprefix sum

Product of Array Except Self

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

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

The Capgemini OA reported in September 2026 hands you Product of Array Except Self, and the whole thing hinges on one plain array used twice. No hash map, no heap, just the output array doing double duty. You've probably seen this one, but under a timer people still reach for division and get burned by the zero case. The rules here ban division anyway, and the O(n) requirement rules out the nested loop. If you blank mid-assessment, StealthCoder is the silent safety net running invisibly on your desktop, but the idea is short enough to own tonight.

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 is prefix and suffix products. Fill answer[i] with the product of everything to the left of i in a forward pass, keeping a running variable. Then sweep backward with a second running variable for the right side, multiplying it into answer[i]. Two passes, O(n) time, and the output array doesn't count as extra space, so you stay inside the constraint. The common pitfall is using division, which breaks on zeros and is banned here anyway. Example 2 with [-1,1,0,-3,3] is your zero test. Another slip is starting the prefix at 0 instead of 1, which wipes out every result. Check [2,3] by hand before you submit. If your head goes blank during the live Capgemini assessment, StealthCoder can hand you the two-pass solution, but write this once yourself first.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as product of array except self. If you have time before the OA, drill that.

⏵ The honest play

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

Capgemini reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Product of Array Except Self FAQ

What's the trick in Product of Array Except Self?+

Build a left-product pass and a right-product pass. Store left products directly in the output array, then walk backward with a running right product and multiply it in. No division needed, and it handles zeros naturally because nothing is ever divided.

Why can't I just divide the total product by nums[i]?+

The problem forbids division. Even if it didn't, zeros break it. One zero makes every other position zero, and two zeros zero the whole array. Example 2 in the Capgemini problem tests exactly that case.

How hard is this one really?+

Medium on paper, easy once you've seen prefix and suffix products. The code is about ten lines. Most failures come from off-by-one initialization or allocating extra arrays when the constraint says to reuse the output.

Is the O(1) extra space requirement strict?+

The output array doesn't count as extra space. So you can use it to hold left products, then use one scalar variable for the running right product. Two separate prefix and suffix arrays would work but miss the space goal.

How do I prepare for this in 48 hours?+

Write it from scratch twice without looking. Trace [1,2,3,4], [-1,1,0,-3,3], and [2,3] by hand. Initialize running products to 1. Then spend the remaining time on other array problems, since this pattern shows up in many variants.

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

OA at Capgemini?
Invisible during screen share
Get it