Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5761 |

@blackshadows | 5715 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4944 |

@saiujwal13083 | 4506 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3516 |

@sushant_a | 3459 |

@verma_ji | 3341 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@aroranayan999 | 1115 |

@bt8816103042 | 739 |

@SherlockHolmes3 | 447 |

@codeantik | 441 |

@SHOAIBVIJAPURE | 430 |

@shalinibhataniya1097 | 408 |

@ShamaKhan1 | 392 |

@neverevergiveup | 381 |

@amrutakashikar2 | 355 |

@mahlawatep | 353 |

@murarry3625 | 352 |

Complete Leaderboard |

Given an array A of N positive numbers. The task is to find the first Equilibium Point in the array.

Equilibrium Point in an array is a position such that the sum of elements before it is equal to the sum of elements after it.

**Example 1:**

**Input:
**N = 1
A[] = {1}
**Output: **1**
Explanation: **Since its the only
element hence its the only equilibrium
point.** **

**Example 2:**

**Input:
**N = 5
A[] = {1,3,5,2,2}
**Output: **3**
Explanation: **For second test case
equilibrium point is at position 3
as elements before it (1+3) =
elements after it (2+2).

**Your Task:**

The task is to complete the function **equilibriumPoint()** which takes the array and N as input parameters and returns the point of equilibrium. Return -1 if no such point exists.

**Expected Time Complexity: **O(N)

**Expected Auxiliary Space:** O(1)

**Constraints:**

1 <= N <= 10^{6}

1 <= A[i] <= 10^{8}

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Equilibrium Point

...