getting wrong output
ide: https://ide.codingblocks.com/s/225206
Matrix queries - 1
@Vishal123
Actually there is a minor logical error. See if you build your segment tree with node=0, then your child node should be 2node+1 and 2node+2 and if you build your segment tree with node =1, then child nodes should be 2node and 2node+1.
In your code you build your segment tree with node=0 and take child as 2node and 2node+1, which is wrong.
So change line 52 to build(1 , 0 ,n-1); and line 57 to query(1 , 0 , n-1 , x-1 , y-1 , ans);