Login

All Problems

Problem title

Difficulty

Avg time to solve

Special Sum

Easy

15 mins

Convert a binary tree to its sum tree

Easy

15 mins

Snake and Ladder

Moderate

30 mins

Shortest Alternating Path

Moderate

10 mins

Binary Tree Zigzag Traversal

Easy

15 mins

Minimize the maximum difference between adjacent elements in an array

Easy

15 mins

Increasing Subsegment

Moderate

15 mins

NINJA'S INTERVAL

Easy

15 mins

Magnet Array Problem

Easy

15 mins

Count Subarrays Having Product Less Than K

Moderate

25 mins

Problem

Submissions

3

Avg. time to solve

15 min

Success Rate

85%

Problem Statement

```
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.
```

```
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.
```

```
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.
```

```
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.
```

```
1 <= T <= 100
2 <= N <= 1000
0 <= ARR[i] <= 10000
Time Limit: 1 sec
```

```
You do not need to print anything. It has already been taken care of. Just implement the given function.
```

```
2
2
1 3
5
1 2 4 8 16
```

```
2.000000
1.425537 3.096679 6.544921 13.734375
```

```
1
4
1 3 5 10
```

```
1.792480 4.077148 8.378906
```

Console

Sample Test Case

Custom Test Case

Download Test Cases

Test Case 1

Test Case 2

Test Case 3

Saving Code...

Full Screen Mode

Change Language

Change Theme

Solution submission not allowed

Save Code

Reset Code