Space after poping all elements

Assume I am using extra space for writing a program like list. If after writing a program I get my result from the extra space and then in the end I pop all the elements in the list until it becomes empty. Won’t it be constant space then??

hi @govilayush the space complexity will be calculated according to the maximum amount of extra space you take. So for example you are making an extra array of all the elements, and you delete the array in the end, the space complexity will still be O(n)

Why the space complexity is still O(n)? I have deleted the array in the end so it should be constant right??

@govilayush but the maximum extra space occupied was still O(n) right

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.