Medium
Quiz
#238 Product of Array Except Self
APPROACH
Given an integer array nums, construct and return an array answer where answer[i] is the product of all elements of nums except nums[i].
Every prefix and suffix product is guaranteed to fit in a 32-bit integer.
Your solution must run in O(n) time and must not use the division operator.
Example 1:
Input: nums = [1,2,3,4]
Output: [24,12,8,6]
Example 2:
Input: nums = [-1,1,0,-3,3]
Output: [0,0,9,0,0]
1 of 4
1:00
What is the optimal approach for this problem?