I was in an interveiw and the interviewer asked me: What is the fastest way to create a list of all zeros in Python with length = n. My answer was:
l = [0 for i in range(n)]
Which is of order O(n). It was rejected as the interviewer told me the code bellow runs in O(1).
l = [0]*n
My question is, how Python manages to create this list in O(1)?