Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Issue #1

Open
JitenderBhati opened this issue Dec 11, 2021 · 0 comments
Open

Code Issue #1

JitenderBhati opened this issue Dec 11, 2021 · 0 comments

Comments

@JitenderBhati
Copy link

For question no 16.c of arrays there is a minor issue in Method 3

int findEquilibriumIndex(int a[],int n){
int i = 0,j;
int sum = 0, sumLeft = 0;

for(i=0; i<n; i++){
	sum += a[i];
}
for(j=0;j<n;j++){
	sum = sum - a[j];
	**sumLeft += a[j];** //Should have come after if condition
	if(sum == sumLeft){
		return j;
	}
}
return 0;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant