Problem Comrades

Hello this is my code https://ide.codingblocks.com/s/315910, please tell me where am i getting wrong as i tried a lot and i’m unable to find it

You need to change the way you are using segment tree. One simple dry run will tell you what is wrong.

When you are querying or updating in the segtree, update or query in the range (tin[l] + 1, tout[l]), instead of (tin[l], tout[l])

also keep in mind to handle the special case of leaf node, where tin[i] == tout[i].

Thanx a lot yash i got my mistake