HomePremium · ₹1199
← All questions

TypeAhead cache with LRU eviction

Medium
Was this asked in an interview?

Build a typeahead suggestion cache with Least-Recently-Used eviction.

Problem

Implement TypeAheadCache(capacity) whose fetchSuggestions(query) returns cached results when present (and marks them recently used), otherwise fetches from the API and stores them, evicting the least-recently-used entry when over capacity.

TypeAhead cache with LRU eviction — JavaScript Interview Question | Mentoxis