189. Product of Array Except Self

MediumArray

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]. You must write an algorithm that runs in O(n) time and without using the division operation.

Examples

Input: [1,2,3,4]

Output: [24,12,8,6]

Explanation: Public test case for Product of Array Except Self

Constraints

  • 2 <= nums.length <= 10^5
  • -30 <= nums[i] <= 30
Loading...

Run checks all cases above. Submit evaluates all test cases.