help required in spoj problem KGSS



Can someone please help me with this [problem][1] from spoj on segment trees. I am storing maximum and second maximum element at each node of tree but getting wrong answer.
Here is my

Any help is appreciated.:)



There is a small mistake. The update operation “sets the value of A to x*”, not to max(A*, x).


Thanks man! Helped a lot :slight_smile: