Skip to content

Time Complexity O(1), O(log n) - What "Fast" Means ​

This notation shows whether the time taken stays the same no matter how much the data grows.

NotationMeaningAnalogy
O(1)Instant, regardless of how much data there isLooking at your ticket number and opening that locker right away
O(n)Gets slower in proportion to the amount of dataOpening boxes one by one from box 1 to the end
O(log n)Even if the data grows 100x, only a few steps are addedSearching by cutting the range in half each time

Why the requirements say "insert/delete/move must be O(1)": LRU tracking happens on every command, so it has to be instant.

Summary ​

ConceptPlain-language summary
O(1)Handled instantly even as data grows

Source: Codyssey-B1/B5-1