Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8633ea6

Browse files
author
applewjg
committed
update
Change-Id: Icfa6f730f9d22f475366f1f0acee0841dd01683c
1 parenta1862bb commit8633ea6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎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
privateintcapacity;
2121
publicLRUCache(intcapacity) {
2222
this.capacity =capacity;
23-
map =newLinkedHashMap<Integer,Integer>(capacity);
23+
map =newLinkedHashMap<Integer,Integer>(capacity +1);
2424
}
2525

2626
publicintget(intkey) {
@@ -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)

[8]ページ先頭

©2009-2025 Movatter.jp