Why is the input 2,[set(2,1),set(2,2),get(2),set(1,1),set(4,1),get(2)] expected [2,-1]?


  • 0
    K

    Why is the input 2,[set(2,1),set(2,2),get(2),set(1,1),set(4,1),get(2)] expected [2,-1]?

    I think it will get [2,2]. Because when set(4,1), key=2 was used 3 times, key=1 would be replaced.


  • 0
    W

    LRU(Least Recently Used) would like to discard the least recently used items first.

    What you are talking about is LFU(Least Frequency Used), which Counts how often an item is needed and those that are used least often are discarded first.


  • 0
    K

    It is so kind of you! I got it now. Thanks!


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.