CSUBQ--help !

can anyone explain the purpose of combine function(what it actually does ) in dis solution CodeChef: Practical coding for everyone for dis question CodeChef: Practical coding for everyone !! Thanks in advance : )

I have discussed the very same approach in my editorial here . My solution too has a node struct and a similar combine function, explained in editorial.

Hope you find it helpful. :slight_smile:

In normal segtree questions if you want to find the minimum element in the range then you write this tree[node]=min(tree[2node],tree[2node+1]) which means you are assigning the minimum value present in both the ranges associated with tree[2node] and tree[2node+1] to tree[node] (indirectly combining the both ranges), in the same way he is combining the two nodes using combine function. But here the purpose is not finding the minimum element he implemented his own combine function.

thanks bro…got it !

thanks bro…done it !