Coding Challenge

Product of Array Except Self

Medium
arrayprefix-suffix

Build an output array where each index holds the product of all other elements.

Return an array answer where answer[i] equals the product of all numbers in the input except nums[i]. Do not use division.

Examples

Input: nums = [1,2,3,4]

Output: [24,12,8,6]

Constraints

  • 2 <= nums.length
  • Products fit in 32-bit integer prefix/suffix range

Preparing your coding workspace...