FastPrepLRU Cache with Concurrency Follow-Up
Problems/LRU Cache with Concurrency Follow-Up

LRU Cache with Concurrency Follow-Up

Confluent logoConfluent● MediumFULLTIMENEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Three firsthand reports ask for an LRU cache, including put and get APIs and a doubly linked list written by hand. A separate firsthand Staff-level report describes a cache similar to LRU and says the follow-up was about concurrent reads, writes, and locking. Our tests run one command after another. The talk about threads is in the editorial, because get changes recency. Our version is about 94% the same as the reported questions.

Process a sequence of operations on a least recently used cache with capacity capacity.

  • PUT key value inserts or updates a key. An update makes the key most recently used. If a new insertion exceeds capacity, evict the least recently used key.
  • GET key returns the stored value, or -1 when the key is absent. A hit makes the key most recently used; a miss does not change recency.

Return all GET results in operation order. Operation fields are decimal integers separated by one space.

Function

runLRU(capacity: int, operations: String[]) → int[]

Examples

Example 1

capacity = 2operations = ["PUT 1 10","PUT 2 20","GET 1","PUT 3 30","GET 2","GET 3"]return = [10,-1,30]

The lookup of key 1 makes key 2 least recently used, so inserting key 3 evicts key 2.

Example 2

capacity = 1operations = ["PUT 5 7","PUT 5 9","GET 5","PUT 6 4","GET 5"]return = [9,-1]

Updating key 5 replaces its value without adding a second entry. Inserting key 6 later evicts it.

Example 3

capacity = 3operations = ["GET 8","PUT 8 0","GET 8"]return = [-1,0]

The first lookup misses. After insertion, a stored value of 0 is returned normally.

Constraints

  • 1 <= capacity <= 10^5
  • 1 <= operations.length <= 2 * 10^5
  • Every operation is exactly GET key or PUT key value.
  • -10^9 <= key, value <= 10^9

More Confluent Onsite Interview questions

  • Implement tail -nPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Sudoku Board ValidationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Sudoku Puzzle SolverPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Sequential Phrase Search Across DocumentsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Bounded Combination Sum with Signed CandidatesONSITE INTERVIEW · Seen Oct 2026
  • Detect a Silent SensorONSITE INTERVIEW · Seen Sep 2026
  • Build an Inverted Document IndexONSITE INTERVIEW · Seen Sep 2026
  • Combination Sum with Unlimited ReuseONSITE INTERVIEW · Seen Sep 2026
  • Word Search Across DocumentsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Windowed Key-Value MapPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2025

Similar questions at other companies

  • LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Least Recently Used CacheMicrosoft · OA · PHONE SCREEN · ONSITE INTERVIEWMicrosoft interview questions
  • LRU CacheAMD · ONSITE INTERVIEWAMD interview questions
  • LRU CacheApple · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
  • Least Recently Used CacheByteDance · PHONE SCREEN · ONSITE INTERVIEWByteDance interview questions
  • LRU Cache with Hit and Miss CountersLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • Least Recently Used CacheGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
  • LRU CacheIntuit · ONSITE INTERVIEWIntuit interview questions
  • LRU CacheOracle · ONSITE INTERVIEWOracle interview questions
  • Aligned Free-List Memory AllocatorHudson River Trading · ONSITE INTERVIEWHudson River Trading interview questions

Interview reports that mention this question

  • Confluent Older Concurrency Rounds: 12 Experiences (Part 2 of 2)
  • Confluent Concurrency Interviews: 28 Experiences (Part 1 of 2)
  • Confluent Coding and System Design Questions: 33 Questions

Confluent interview experiences

  • Confluent SWE OA, Coding and Design Interviews: 19 Experiences
  • Confluent File Manipulation Round (tail -n): 19 Experiences
All Confluent interview questionsSee Confluent hiring insights
Saved
class Solution {
    public int[] runLRU(int capacity, String[] operations) {
      // Write your code here.
    }
}
Checking account…