Software Engineer

Case File: The Least Recently Used

A slow lookup is repeated thousands of times, so a cache keeps the answers asked for most recently and throws out the least recently used one when it is full. Write the LruCache class with get, put, size and keys, with exact rules for updates and ordering. The operations are replayed on a cache of your own, including sizes and sequences you cannot see.

50 min

Case File: The Least Recently Used

A slow lookup is repeated thousands of times, so a cache keeps the answers asked for most recently and throws out the least recently used one when it is full. Write the LruCache class with get, put, size and keys, with exact rules for updates and ordering. The operations are replayed on a cache of your own, including sizes and sequences you cannot see.

In this lesson:

  • python
  • classes
  • cache
  • data structures
  • design
  • case-file

๐Ÿ”’ This lesson is part of a paid plan

This lesson is part of the Pro plan. Upgrade to unlock the full lesson, the labs and the exam.

Upgrade Now

This lesson is part of a paid plan

Upgrade to Pro to unlock this course, its labs and its exam.

View Pricing Plans