home/coding/prompt-69

Prompt

GPTClaudeDeepSeek··1,256 copies·updated 2026-07-14
prompt-69.prompt
Implement an LRU (least-recently-used) cache in Python.

Provide a class `LRUCache` with:

- `LRUCache(capacity)` — fixed positive integer capacity.
- `get(key)` — return the value, or `-1` if the key is absent. A successful `get` counts as a use.
- `put(key, value)` — insert/update. A `put` counts as a use. When over capacity, evict the least-recently-used key.

Put the class in a single Python code block. It will be imported as `from solution import LRUCache`.

when to use it

Community prompt sourced from the open-source GitHub repo Green-PT/honey-for-devs (MIT). A "Prompt" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.

tags

codingcommunitydeveloper

source

Green-PT/honey-for-devs · MIT