Problem 3 c++ stl quiz II

Shouldn’t time complexity be O(n) because i is increasing linearly and vector is not increasing and is of fixed size n.
So when i becomes n till that time i is called for value 0,1,2…n. So why its time complexity is O(n^2)

each time you pass a vector it has to be copied which is O(N) proces so the time complexity increases to O(N^2)

1 Like

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.