Can someone tell me what is wrong in my implementation of lazy propagation in this [PROBLEM][1]. If my lazy node is 1 then that segment needs to be flipped and if 0 then no change. I am just able to pass sample test case.
Someone please help:)
[2].
[1]: https://www.codechef.com/problems/FLIPCOIN
[2]: https://www.codechef.com/viewsolution/20433084
#HERE is your accepted solution…
Your bug is
lazy[node*2]=1;
lazy[node*2+1]=1;
Should be
lazy[node*2]=! lazy[node*2]);
lazy[node*2+1]=! lazy[node*2+1];
2 Likes
@l_returns Thanks for the help. Sorry for the delay. Can you please suggest some problems on segment tree to practice from basic to intermediate level
You are welcome
You need questions on lazy propagation or simply on segment tree ?
simply on segment tree would be great sir