Equilibrium index of an array | GeeksforGeeks

preview_player
Показать описание

This video is contributed by Harshit Verma

Please Like, Comment and Share the Video among your friends.

Also, Subscribe if you haven't already! :)
Рекомендации по теме
Комментарии
Автор

Bhai kitna ganda explaination h apka bikul v smj nhi ata aur kamse kam approach toh bataoo ki us qus tak kese approach karenge bs sidha line padhne lg jateh hoh solution ka aur woh toh first class ka bacha v krlega

bipinsingh
Автор

Dear sir I want to practice competitive programmings, where do I have to register for the guidance or tutorials?? Please reply ASAP

skasif
Автор

Better approach is present on teck dose channnel

hamidansari
Автор

It will wrong for -7, 1, 5, 3, -4, 3, 1 but the some of -7, 1, 5, 3, -4, 3 is 1 and is equal to 1 and the above solution can't find this( first method)

codevlogs
Автор

int equilibriumPoint(long long a[], int n)
{

long long sum=0, leftsum=0;
for(int i=0;i<n;i++)
{
sum+=a[i];
}
for(int i=0;i<n;i++)
{
//long long t=sum-a[i];
sum=sum-a[i];
if(leftsum==sum)
{
return i+1;
}

leftsum+=a[i];
}
return -1;
}

wecan
Автор

but the first method is giving wrong output for 2, 4, 4, 5, 4, 1

shubhd
Автор

Wasted 2 hours.. It will for only for some inputs..

dhananjayarjundavala
Автор

i cant understand firstly you do same thing sum-=arr[i] and leftsum+=arr[i]
firstly you told us equlibrim point is that point in which left part is equal to right part and you compare the whole array by just giving - sign i cant understand

topthingwhichyoushouldkn