If i have an update condition like if i want to assign all elements in range (l,r) with a value x(x!=0) and i have many updates like this , for example —
l r x
1 4 2
3 4 3
7 8 9
now if i want to query for an index y , then can i do this using BIT? I have come up with this solution but it isn't working —
update(l, x)
update(r+1, 0) #0 means index still unassigned.
now if i query for like index 4(read(4) — read(4-1)) i am not getting the correct answer. Is my approach correct ?