Shouldnt the complexity be O(n)
Why is this O(n^2)
@shrey_codes,
the time complexity for this problem should be O(n^2) , since the function is called by value thus at each call the vector will be copied to v and since copying vector of size n takes o(n) time and n function calls will result in time complexity being o(n^2)
if vector have been passed by address or reference then the time complexity would have been O(n)
In case of any doubt feel free to ask
mark your doubt as resolved if you got the answer