array = ["A", "B", "C", "D"]
for the given array it takes O(1)
to point to the first index which is 0. So if I type array[0]
, it takes O(1)
to point to "A"
. But if i write array[-1]
which points to the last index 3. Does it iterate through the entire array to get the last index or it knows that the array ends at index 3 by default ?
In other words how is array[-1] is implemented in python?