#K49497. Array Product Except Self
Array Product Except Self
Array Product Except Self
Given an array of integers, 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. Mathematically, for an array \( arr \) of length \( n \), the answer for each index i is given by:
\( output[i] = \prod_{\substack{j=0 \\ j \neq i}}^{n-1} arr[j] \)
If the array contains only one element, return [0].
inputFormat
The input is read from standard input (stdin). The first line contains a single integer ( T ) representing the number of test cases. Each of the following ( T ) lines contains a list of space-separated integers representing one test case.
outputFormat
For each test case, output a single line to standard output (stdout) containing space-separated integers. Each integer is the product of all the elements in the test case array except the one at that particular index.## sample
2
1 2 3 4
5 6 2
24 12 8 6
12 10 30
</p>