test : 2,[set(2,1),set(1,1),get(2),set(4,1),get(1),get(2)]
expected : [1,-1,1]
Why does the second expected value is -1? I thought because of set(4,1) the entry (2,1) is deleted because the last one we use is 2 (from get(2) ). Why does get(1) should return -1?
@steven.adrianus 'get' is also see as one use.
I don't understand what you said. So when set(4,1) , which one get popped out and why?
@steven.adrianus when set(4,1), (1,1) should be popped out, because (2,1) has just be used(for the action get(2)). So the least used is (1,1), we have to pop it out.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.