File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
main/java/g0101_0200/s0146_lru_cache
test/java/g0101_0200/s0146_lru_cache Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 66import java .util .HashMap ;
77import java .util .Map ;
88
9- public class LruCache {
9+ public class LRUCache {
1010 private static class LruCacheNode {
1111 int key ;
1212 int value ;
@@ -26,7 +26,7 @@ public LruCacheNode(int k, int v) {
2626 // remove here
2727 private LruCacheNode tail ;
2828
29- public LruCache (int cap ) {
29+ public LRUCache (int cap ) {
3030 capacity = cap ;
3131 }
3232
@@ -120,3 +120,10 @@ private void moveToHead(LruCacheNode node) {
120120 head = node ;
121121 }
122122}
123+
124+ /*
125+ * Your LRUCache object will be instantiated and called as such:
126+ * LRUCache obj = new LRUCache(capacity);
127+ * int param_1 = obj.get(key);
128+ * obj.put(key,value);
129+ */
Original file line number Diff line number Diff line change 55
66import org .junit .jupiter .api .Test ;
77
8- class LruCacheTest {
8+ class LRUCacheTest {
99 @ Test
1010 void lruCache () {
11- LruCache lruCache = new LruCache (2 );
11+ LRUCache lruCache = new LRUCache (2 );
1212 // cache is {1=1}
1313 lruCache .put (1 , 1 );
1414 // cache is {1=1, 2=2}
You can’t perform that action at this time.
0 commit comments