#K86637. Product of Array Except Self
Product of Array Except Self
Product of Array Except Self
Given an array \(nums\) of integers, return an array \(result\) such that each element \(result[i]\) is equal to the product of all the elements in nums except \(nums[i]\). You must solve this problem in \(O(n)\) time without using division.
Note: The final product for each index \(i\) is computed as:
\(result[i] = \prod_{j \neq i} nums[j]\)
inputFormat
The first line contains a single integer \(n\) representing the number of elements in the array. The second line contains \(n\) space-separated integers.
outputFormat
Output \(n\) space-separated integers. The \(i\)-th integer is the product of all the input integers except the \(i\)-th one.
## sample4
1 2 3 4
24 12 8 6