Can using vector instead of array cause TLE in some of the questions?

i just wanted to know if yes then where to use it and where to not to use it(vector)

no, if you use vector in a similar way than array (without reallocations)

1 Like

Yes,
Used vector here: It gave TLE
Used array here: Got accepted
These 2 are the solutions of same question.

But this condition happens rarely, when the time limit is very strict.
But for knowledge remember that arrays are faster than vector.

1 Like

the problem is not the use of vector but how you use it. Check the running time of your solution that uses vector when you are not making a copy of vector a each time you call the function construct

https://www.codechef.com/viewsolution/34920087

3 Likes

Okey, sorry that was a fault on my side.
But anyway thanks for correcting me, appreciate it.

2 Likes