
If you are running a custom test case, then 1 will be printed if the returned array is correct, else 0 will be printed.
If you wish to check your output then use print statements before returning the final answer.
If N = 5, then the answer can be { 1, -2, 3, -6, 4 }, as: 1 + ( -2 ) + 3 + ( -6 ) + 4 = 0.
Note that { 1, -3, 5, -2, -1 } is also a valid answer for N = 5.
The first line contains a single integer ‘T’ denoting the number of test cases, then each test case follows:
The first and only line of each test case contains a single integer ‘N’ denoting the number of distinct digits to be selected.
For each test case, print the N elements that sum up to 0.
Output for each test case will be printed in a separate line.
You are not required to print anything; it has already been taken care of. Just implement the function.
1 <= T <= 10
1 <= N <= 10000
Time limit: 1 sec
For N = 1, return { 0 }
For N = 2, return { -1, 1}
For N = 3, return { -1, 0, -1}
For N = 4, return { -2, -1, 1, 2}
For N = 5, return { -2, -1, 0, 1, 2} and so on…
Notice that we can just include elements from 1 to N / 2 and elements from -1 to -N / 2. And if the given N is odd we should also include 0.
The steps are as follows :