Product of Array Except Self

medium 2× XP
Unit 19 · Selection0/3 to milestone

For each position, return the product of all other numbers, without using division. Division breaks on zeros, and the interviewer will usually ban it anyway.

Implement product_except_self(nums) in O(n)O(n) time: compute the product of everything to the left of each position, then multiply by the product of everything to the right.

#arrays#prefix-sums2 visible + 2 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Product of Array Except Self · TechGradify