FreeCareerPath
Build the PrimitiveMedium

Product of Array Except Self

Write `product_except_self(nums)` returning a list where each position holds the product of every other element. product_except_self([1, 2, 3, 4]) -> [24, 12, 8, 6] Division is banned, and the ban is the point: dividing by each element breaks the moment the list contains a zero. Build a prefix pass and a suffix pass instead, and the zero cases handle themselves with no special-casing at all.

What to expect: A timer starts when you begin. Edit the starter code, run it against the test suite as many times as you like, then finish when you're done. The reference solution and interviewer follow-up questions unlock only after you finish.

Log in to start this session

Timed sessions and your results for "Product of Array Except Self" are saved to your account — logging in takes a few seconds.

Product of Array Except Self — FreeCareerPath