FunctionRacerProblemsRace

Product of Array Except Self

MediumArraysPython, JavaScript, TypeScript, Java, C++

Return a list answer where answer[i] is the product of every number in nums except nums[i].

Try to do it without using division.

Example 1

nums [1,2,3,4]
returns [24,12,8,6]

For index 0: 2*3*4 = 24. For index 3: 1*2*3 = 6.

Example 2

nums [2,0,5]
returns [0,10,0]

Only the index holding 0 gets a nonzero product: 2*5 = 10.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Arrays problems