Magnet Array Problem

Posted: 1 Mar, 2021
Difficulty: Easy

PROBLEM STATEMENT

Note :

``````An equilibrium point is a point where net force is 0 i.e repulsive force of left side magnets is equal to the repulsive force of right side magnets.

If there are N magnets, then there will be N - 1 equilibrium points.

The array “ARR” which denotes the positions of the magnets is in a sorted fashion.
``````
For example :
``````If ARR = {1, 3} , then the output will be 2.

Explanation: For two points, the mid-point will have a net force of 0 because the distance from the mid-point will be equal.
``````
Input Format :
``````The first line contains an integer ‘T’ which denotes the number of test cases or queries to be run. Then the test cases are as follows.

The first line of each test case contains an integer ‘N’ which denotes the number of magnets.

The second line of each test case contains ‘N’ space-separated integers denoting the positions of the magnets on the x-axis.
``````
Output Format :
``````For each test case, print all the positions of zero net force with accuracy up to 3 decimal points.

Print the output of each test case in a separate line.
``````
Constraints :
``````1 <= T <= 100
2 <= N <= 1000
0 <= ARR[i] <= 10000

Time Limit: 1 sec
``````
Note :
``````You do not need to print anything. It has already been taken care of. Just implement the given function.
``````