I'm trying to solve a problem with O(1) in space. Could anyone help me determine if the following code is taking O(1) space?
I got a list as input and every time I ran a loop I do
list = list[:len(list)/2+1]
Does list re-allocation use the original memory of that list, or should it create extra memory usage? Thanks.