How can the time complexity be n^2

as only n calls are made

Hey @sukritbansal01
Assumming vector is defined as vector< int > v
its time complexity will be O(n^2).
because total n calls wiil be there and on every call vector get copied to new vector which is O(n) for each call . therefore O(n^2) for n calls
Its not passed by reference but by copy
so for each recursive call a copy of vector is made
So rec reln in terms of time complexity is T(n)=T(n-1) + O(n) ==>T(n-2)+2O(n) ==> T(1)+nO(n)==O(n^2)

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.

Can I have the list of answers plz? Not able to find my mistake

Hey Nothing such list is available :slight_smile:
You can always open a doubt regarding the questions you are not able to understand