Can somebody explain this?

I was solving this problem:
AC code:
RE error code:
The difference between the above 2 codes is just a variable “root” at line 49 which is never used in the code after its initialization.I want to ask how can such a variable even causes a difference in verdicts?
@ssjgz @everule1

You are accessing out of bounds indices in segtree array, either make the size 4x the size of input, or make the range in upd and qry [1, n], instead of [0, n].

1 Like

Thanks a lot buddy! got an AC :smile: