Why does O(n^2) time complexity

its a one time recursion function

hello @punitsehrawat423
since the vector is being passed by value, it will be copied to a new vector in each call. Copying the vector will take O(n) time, doing so n times will make the overall time complexity of the program as O(n*n)

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.

1 Like