Could you tell me please, if I use for i in range(n)
, does python creates a range of 0 .. n-1, and iterates elements in this container (O(n) extra space), or it use only 1 vatiable (O(1)) space)
From one side, I thought, if we can convert range to list, then using range function creates a container (O(n)).but from the other side, instead of using for i in range(n)
, we can use while i < n ...
O(1).