Skip to content

Commit 8633ea6

Browse files
author
applewjg
committed
update
Change-Id: Icfa6f730f9d22f475366f1f0acee0841dd01683c
1 parent a1862bb commit 8633ea6

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

LRUCache.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Author: King, nkuwjg@gmail.com
2+
Author: Andy, nkuwjg@gmail.com
33
Date: March 12, 2014
44
Problem: LRU Cache
55
Difficulty: Hard
@@ -20,7 +20,7 @@ public class LRUCache {
2020
private int capacity;
2121
public LRUCache(int capacity) {
2222
this.capacity = capacity;
23-
map = new LinkedHashMap<Integer, Integer>(capacity);
23+
map = new LinkedHashMap<Integer, Integer>(capacity + 1);
2424
}
2525

2626
public int get(int key) {
@@ -37,4 +37,4 @@ public void set(int key, int value) {
3737
if (map.size() > capacity)
3838
map.remove(map.entrySet().iterator().next().getKey());
3939
}
40-
}
40+
}

0 commit comments

Comments
 (0)