Product of All Array Elements Except Self
Calculate the product of all the elements of an array except the current element.
Statement
Given an integer array, nums
, return an array, answer
, such that answer[i]
is equal to the product of all the elements of nums
except nums[i]
.
Examples
Example 1
Sample input
nums = [1, 2, 3, 4]
Expected output
[24, 12, 8, 6]
...Access this course and 1400+ top-rated courses and projects.