Why is the time complexity O(N^2), it should be O(N), as the function will require a total of N steps?
Doubt Regarding Time Complexity
@yogekgargdev
The vector was not passed by reference, Therefore on each function call, a fresh copy of vector is created resulting in overall complexity of O(n^2).