← All problems

Product of Array Except Self

medium

Given an integer array nums, return an array answer where answer[i] is the product of every element in nums except nums[i].

Do it in O(n) time without using division, and without the division operator anywhere in your solution.

Example

Input: nums = [1, 2, 3, 4]
Output: [24, 12, 8, 6]
Loading...