Product of Array Except Self

00:00
MediumArrayPrefix Product
AmazonGoogleFacebook

Return array where answer[i] = product of all elements except nums[i]. O(n) time, no division operator.

Examples

Input → [1,2,3,4]
Output → [24,12,8,6]
Input → [-1,1,0,-3,3]
Output → [0,-3,0,9,0]
Input → [2,3]
Output → [3,2]