ArticlesCost
Constant time
Work that stays flat as the input grows, such as reading one array slot or pushing onto the end.
O(1) means the work does not grow when the input grows. Reading nums[0] is the picture: the runtime jumps to that slot from the start of the array. It does not walk from the head, so a longer array does not make that one read slower.
Constant does not mean instant, and it does not mean the work is tiny. It means the work stays flat while n changes. Pushing onto the end of an array is in the same family on average: one write, and nothing in front of it has to slide. A hash map get is treated as O(1) on average for the same reason, even though one unlucky key can take longer.
When you reach for an index, a stack push, or a map lookup, say O(1) and then check that you did not hide a loop inside the helper. A function that looks like one step and scans the whole array is not constant time.