Skip to content

Commit 3df5113

Browse files
authored
**************************
1 parent 9bb1924 commit 3df5113

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Equilibrium Point/program.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
int equilibriumPoint(long long a[], int n)
2+
{
3+
// Your code here
4+
long long sl=0,sr=0;
5+
for(int i=0;i<n;i++)
6+
{
7+
sl+=a[i];
8+
}
9+
for(int i=n-1;i>=0;i--)
10+
{
11+
sr+=a[i];
12+
if(sl==sr)
13+
{
14+
return i+1;
15+
}
16+
else
17+
{
18+
sl-=a[i];
19+
}
20+
}
21+
return -1;
22+
}

0 commit comments

Comments
 (0)