Why the complexity is O(N^2)

there is 2 operations in each iteration i.e. previous string plus the present i value.
Then why we consider n operation in nth iteration.
So, according to this time complexity should be 2N.

Hey @theravenclaw2903 You are right that complexity will be 2N but as you know time complexity is nothing but Order of time in which you code runs and by order we meant Power of N so for the case 2N power is 1 therefore we only take in account that time complexity of this code is O(N). i.e. order of N.

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.