【test case error?】Is there something wrong with 2,[get(2),set(2,6),get(1),set(1,5),set(1,2),get(1),get(2)]


  • -1
    M
    Input:	2,[get(2),set(2,6),get(1),set(1,5),set(1,2),get(1),get(2)]
    Output:	[-1,-1,2,-1]
    Expected:	[-1,-1,2,6]
    

    but as we can find there is just two keys 1 and 2 so maybe my answer is right?


  • 0
    Y

    Expected: [-1,-1,2,6]
    That is right.

    Your output is wrong.


  • 0
    M

    why?
    the LRU is change as follow:
    get(2) -->{}
    set(2,6) -->{(2,6)}
    get(1) -->{(2,6)}
    set(1,5) -->{(2,6)(1,5)}
    set(1,2) -->{(2,6)(1,2)}
    get(1)-->{(2,6)(1,2)}
    get(2)-->{(2,6)(1,2)}

    is there anything wrong ,and WHY?


  • 0
    Y

    When the LRU is {(2,6),(1,2)} and get(2), why your output is -1? It should be 6.


Log in to reply
 

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