Skip to content

Commit c3cc881

Browse files
refactor 460
1 parent 769fd73 commit c3cc881

File tree

1 file changed

+0
-32
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+0
-32
lines changed

src/main/java/com/fishercoder/solutions/_460.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,6 @@
33
import java.util.HashMap;
44
import java.util.LinkedHashSet;
55

6-
/**
7-
460. LFU Cache
8-
9-
Design and implement a data structure for Least Frequently Used (LFU) cache.
10-
It should support the following operations: get and put.
11-
12-
get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1.
13-
put(key, value) - Set or insert the value if the key is not already present. When the cache reaches its capacity,
14-
it should invalidate the least frequently used item before inserting a new item.
15-
For the purpose of this problem, when there is a tie (i.e., two or more keys that have the same frequency),
16-
the least recently used key would be evicted.
17-
18-
Follow up:
19-
Could you do both operations in O(1) time complexity?
20-
21-
Example:
22-
23-
LFUCache cache = new LFUCache( 2 /* capacity );
24-
25-
cache.put(1, 1);
26-
cache.put(2, 2);
27-
cache.get(1); // returns 1
28-
cache.put(3, 3); // evicts key 2
29-
cache.get(2); // returns -1 (not found)
30-
cache.get(3); // returns 3.
31-
cache.put(4, 4); // evicts key 1.
32-
cache.get(1); // returns -1 (not found)
33-
cache.get(3); // returns 3
34-
cache.get(4); // returns 4
35-
36-
*/
37-
386
public class _460 {
397
public static class Solution1 {
408
/**

0 commit comments

Comments
 (0)