Query bits Solution

Hello i coppy pasted the code, i got the logic behind the approach but i’m still unclear with the below mentioned line i didn’t got why they have wrote min() function,
could you please explain me with some examples?

//This is in query function
return (p1*pow(2,min(en,r)-mid,mod)%mod+p2)%mod;

@msid78641 this is meant for appropriate right shift,
lets say you query from 3 to 5,
then it can be found from two subqueries of [3,4] and [5,5], also when you combine these two results, you need right shift answer from [3,4] once and then add answer from [5,5].
now min() is required as your focus is only on current subquery(that overlaps with st to en) and not on total query (as for total query, it will updated on parent node!)
hence when en<r, you limit it to en as further right shift is taken care at parent(upper) levels.

For parent nodes en will be larger, so this is guaranteed!