You are viewing a single comment's thread. Return to all comments →
You have initialized p,q,r with 0 which means you are popping out the first inserted elements. by doing : x=x-d[p++];
Instead, you should be popping out from the stack, right?? So, ideally it should be :
int p=a-1,q=b-1,r=c-1; ..... x=x-d[p--];
Can you please explain as of how this works. I am a bit confused into this.. I highly appreciate your help.
Equal Stacks
You are viewing a single comment's thread. Return to all comments →
You have initialized p,q,r with 0 which means you are popping out the first inserted elements. by doing : x=x-d[p++];
Instead, you should be popping out from the stack, right?? So, ideally it should be :
int p=a-1,q=b-1,r=c-1; ..... x=x-d[p--];
Can you please explain as of how this works. I am a bit confused into this.. I highly appreciate your help.