Time limit Exceed

I am using segment tree still it is showing tle
code ide - https://ide.codingblocks.com/s/198769

@souravmunjal2000,
You are using local arrays/vectors in main and then passing them as parameters in build and query functions.
So these pointers will be passed among all internal recursive calls, and result in greater overhead.

  • Try declaring global arrays/vectors, that way you won’t have to pass it as parameters to functions as all functions will have their access already.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.