What is wrong with the following code SPOJ GSS1?

After watching the segment tree video i tried to solve the GSS1 spoj problem.

Problem Link:

My solution:
https://pastebin.com/1GE6DjuF

For the test case
4
-2 1 1 -2
1
1 4
the output must be 2 but my code for some reason prints 0. I cannot figure out the problem with my code. Any help is appreciated.


you can match your code from here.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

1 Like