FastPrepFuture-Aware Cache Eviction
Problems/Future-Aware Cache Eviction

Future-Aware Cache Eviction

Benchling logoBenchling● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Benchling full-time phone screen. We follow the exercise in the report. The report leaves out some input limits and some interface details. We chose those. Our version is about 95% the same as the reported question.

Given requests, the full sequence of key requests known in advance, and a cache that holds at most capacity keys, return, for each request, the key it evicts, or "-" when nothing is evicted. A request is a miss when its key is not in the cache, and the key is then added. On a miss when the cache is full, first evict the cached key whose next request comes latest. A key that is never requested again counts as latest. Break equal next-use ties by evicting the lexicographically larger key.

Function

futureAwareEvictions(requests: String[], capacity: int) → String[]

Examples

Example 1

requests = ["a","a","b","c","b","c"]capacity = 2return = ["-","-","-","a","-","-"]

When c arrives, the cache holds a and b. b is requested again later but a never is, so a is evicted.

Constraints

  • 1 <= requests.length <= 200000.
  • 1 <= capacity <= 1000.
  • Keys contain lowercase letters and digits.

More Benchling interview questions

  • Bounded HTTP Retry FlowPHONE SCREEN · Seen Nov 2025
  • Generate All Contiguous Protein ChainsPHONE SCREEN · Seen Jul 2024
  • Eight-Direction Keyboard Typing TimePHONE SCREEN · Seen Apr 2022
  • Generate Proteins from Contiguous Named SequencesPHONE SCREEN · Seen Aug 2021
  • Next Palindrome NumberPHONE SCREEN · Seen Jul 2021
  • Apply Overlapping HTML Formatting RangesPHONE SCREEN · Seen Feb 2019
  • Validate Nested JSON Against a SchemaONSITE INTERVIEW · Seen Dec 2025
  • Degenerate DNA Substring SearchONSITE INTERVIEW · Seen Jun 2024
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Jul 2021
  • 2048 Move SimulatorOA · Seen Feb 2019

Similar questions at other companies

  • Logger Rate Limiter with Every-Arrival HistoryGoogle · PHONE SCREENGoogle interview questions
  • Propagating Fraud DetectorAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
  • Order and Batch Open-Close LifecycleHudson River Trading · PHONE SCREENHudson River Trading interview questions
  • Pins Violation Log QueriesPinterest · PHONE SCREENPinterest interview questions
  • Resource Reconciler: Plan and Apply CreatesPerplexity AI · PHONE SCREENPerplexity AI interview questions
  • Realized Gains from a Real-Estate Transaction StreamKikoff · PHONE SCREENKikoff interview questions
  • Process On-Call Routing OperationsOpenAI · PHONE SCREENOpenAI interview questions
  • Task Scheduler with CooldownTeradata · PHONE SCREEN
  • Batched Key Fetch CallbacksAnrok · PHONE SCREEN
  • Earliest Car for Each PassengerWhatNot · PHONE SCREENWhatNot interview questions
All Benchling interview questionsSee Benchling hiring insights
Saved
class Solution {
    public String[] futureAwareEvictions(String[] requests, int capacity) {
        // Write your code here.
    }
}
Checking account…