MCPcopy Index your code
hub / github.com/ByteByteGoHq/coding-interview-patterns / get

Method get

java/Linked Lists/LRUCache.java:32–43  ·  view source on GitHub ↗
(int key)

Source from the content-addressed store, hash-verified

30 }
31
32 public int get(int key) {
33 if (!cache.containsKey(key)) {
34 return -1;
35 }
36 else {
37 // To make this key the most recently used, remove its node and
38 // re-add it to the tail of the linked list.
39 remove(cache.get(key));
40 addToTail(cache.get(key));
41 return cache.get(key).val;
42 }
43 }
44
45 public void put(int key, int val) {
46 // If a node with this key already exists, remove it from the

Callers 15

verifySudokuBoardMethod · 0.45
pairSumUnsortedMethod · 0.45
tripletSumMethod · 0.45
putMethod · 0.45
shortestPathMethod · 0.45

Calls 2

removeMethod · 0.95
addToTailMethod · 0.95

Tested by 1

shortestPathMethod · 0.36