O(1) constant time
easy 13 minO(1) means an operation takes a fixed amount of work no matter how large the input is.
Where it shows up
The same pattern appears across everyday software.
Caches in front of databases
Redis and Memcached are giant hash tables. A web server checks the cache with a key such as user:123 and gets the value back in constant time, so a cache with a billion entries answers as quickly as one with ten.
LRU caches in browsers and CPUs
Browsers, CDNs and operating systems keep recently used items in an LRU cache built from a hash map and a doubly linked list. Finding an item, moving it to the front and evicting the oldest are all O(1).
The call stack
Every function call pushes a frame onto the call stack and every return pops it. Both are O(1), which is why calling a function costs the same whether the program is 10 calls deep or 10,000.
Image pixels and lookup tables
An image is a flat array, so the pixel at row r and column c sits at index r × width + c. Graphics code reads any pixel in constant time, and precomputed lookup tables (colour palettes, sine tables) work the same way.
Sets for deduplication
Crawlers, stream processors and analytics jobs keep a set of IDs they have already seen. Checking and adding an ID is O(1) on average, so deduplicating n events costs O(n) instead of O(n²).