#C782. Product of Array Except Self
Product of Array Except Self
Product of Array Except Self
Given an array of integers, your task is to compute a new array such that each element at index i is equal to the product of all the numbers in the original array except the one at index i. Note that you must solve this problem without using division.
Formally, for an array nums of length n, you need to compute:
$$output[i] = \prod_{\substack{0 \leq j < n \\ j \neq i}} nums[j]$$
The input will contain a single integer n (where n \geq 1) and n space-separated integers. The output should be a single line with the computed output array with each element separated by a space.
inputFormat
The first line contains a single integer n (the number of elements in the list). The second line contains n space-separated integers.
outputFormat
Output a single line containing n space-separated integers where the i-th integer is the product of all elements of the input array except the one at index i.
## sample4
1 2 3 4
24 12 8 6