23. Equilibrium Point
Last updated
Was this helpful?
Last updated
Was this helpful?
The problem can be found at the following link:
Petty easy question.
To find the equilibrium point, I calculate the total sum
of the elements in the array. Then,
I iterate through the array and maintain a prefix sum preSum
and subtract the current element from the total sum
.
If the remaining sum == preSum
equals, I return the current index as the equilibrium point.
Time Complexity: O(N)
where N
is the number of elements in the array. We iterate through the array twice: once to calculate the total sum and once to find the equilibrium point.
Auxiliary Space Complexity: O(1)
. We only use a constant amount of extra space to store the sum
and preSum
.
For discussions, questions, or doubts related to this solution, please visit our . We welcome your input and aim to foster a collaborative learning environment.
If you find this solution helpful, consider supporting us by giving a ⭐ star to the repository.