For those who are getting TLE in C++


Pass vector as const and by reference and you won’t get TLE.


Yeah it worked! Could you please explain why?


Because when you pass don’t pass vector by reference, your function call creates a copy of original vector, so it will take extra time to copy, leading to TLE.




Yes, It really worked thanks for sharing …


And why is const nneccesary?


Thanks a lot for sharing man!


Maybe because the original function has declared it as a const vector parameter


It worked, thanks a lot for sharing.