MCPcopy Create free account
hub / github.com/ByteByteGoHq/coding-interview-patterns / get

Method get

kotlin/Linked Lists/LRUCache.kt:25–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23 }
24
25 fun get(key: Int): Int {
26 if (key !in hashmap) {
27 return -1
28 }
29 // To make this key the most recently used, remove its node and
30 // re-add it to the tail of the linked list.
31 val node = hashmap[key]!!
32 removeNode(node)
33 addToTail(node)
34 return node.value
35 }
36
37 fun put(key: Int, value: Int) {
38 // If a node with this key already exists, remove it from the

Callers 1

dfsFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected