One very interesting thing that was pointed out by in video was that since he was not passing vector by reference, the complexity got increased from O(n^2 to n^3).
Can you please explain?
One very interesting thing that was pointed out by in video was that since he was not passing vector by reference, the complexity got increased from O(n^2 to n^3).
Can you please explain?
@shivambehl123,
Because if you pass by value (and not reference) then a copy of the argument is made, which in the case of vector would take O(n) time. So, if you are calling this function n times, then total complexity will be O(n^2).