#K75792. Product Except Self
Product Except Self
Product Except Self
Given an array of integers, compute a new array such that each element at index i of the output is equal to the product of all the numbers in the original array except the one at i. In other words, for an input array \( nums \) of length \( n \), produce an output array \( result \) where:
\( result[i] = \prod_{\substack{0 \leq j < n \\ j \neq i}} nums[j] \)
You must solve this problem without using division. This problem tests your understanding of prefix and suffix products and requires you to loop through the array efficiently.
inputFormat
The input is provided via standard input (stdin). The first line contains an integer \( n \), representing the number of elements in the array. The second line contains \( n \) space-separated integers, which are the elements of the array \( nums \).
outputFormat
Output a single line to standard output (stdout) containing \( n \) space-separated integers. These integers represent the computed array where each element is the product of all other elements except the one at that position.
## sample4
1 2 3 4
24 12 8 6