


Given ‘N’ = 4 and ‘ARR’ = [1, 2, 3, 4].
Then the minimum special sum will be 5 for i = 0 (0-based indexing), which is (1 + 4) = 5.Sum of 1 integer from beginning and end.
For i = 1 it will be (1 + 2) + (3 + 4) = 10
For i = 2 it will be (1 + 2 + 3) + (2 + 3 + 4) = 15
For i = 3 it will be (1 + 2 + 3 + 4) + (1 + 2 + 3 + 4) = 20
All of which are greater than 5.
The first line of input contains an integer ‘T’ denoting the number of test cases.
The first line of each test case contains a single integer N, where ‘N’ is the number of elements of the array.
The second line of each test case contains ‘N’ space-separated integers, denoting the array elements.
For each test case, return the minimum SPECIAL_SUM for ‘i’ in the range [ 0, N-1 ].
The output of each test case will be printed in a separate line.
You don’t need to print anything. You just need to implement the given function.
1 <= T <= 5
1 <= N <= 5 *10^3
-5 *10^2 <= ARR[i] < 5 *10^2
Time limit: 1 sec
The main idea is to calculate the ‘FIRST_SUM’ and the ‘LAST_SUM’ for every index ‘i’ between [0, N - 1].
The main idea is to calculate the ‘FIRST_SUM’ and the ‘LAST_SUM’ for every index ‘i’ between [0, N - 1], instead of calculating FIRST_SUM and LAST_SUM for every ‘i’ we can maintain prefix and suffix sum and for every ‘i’ the SPECIAL_SUM(i) = PREFIX(i) + SUFFIX(n - i - 1).