Min Query 1(Getting TLE)

Why the solution is getting TLE?

In line 31 take vector as reference variable

If your doubt is resolved please mark it as closed.

Its not working.Still getting TLE.

Did you submit it on CB question ? or SPOJ

Submitted this on CB question

Line 17, change vector<ll> arr to vector<ll> &arr

how does this affect the TLE. Can you please explain?

When you don’t use reference variable, each time you send a variable such as vector a new copy is created. So for a vector of size 10^5 it’ll get copied each time the function is called which makes time complexity N^2

If your doubt is resolved please mark it as closed.

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.