Is this test case correct (python)


  • 0
    T

    The problem states:
    set(key, value) - Set or insert the value if the key is not already present. When the cache reached its capacity, it should invalidate the least recently used item before inserting a new item.

    but this test case seems to be expecting a different answer:
    Input:
    2,[set(2,1),set(2,2),get(2),set(1,1),set(4,1),get(2)]
    Output:
    [1,-1]
    Expected:
    [2,-1]

    I would think, based on the specification, that the second set with a key of 2 would be ignored.


  • 1
    A

    It says (though I agree poorly) "SET" it if not present, "INSERT" it if present. Anyway it should be updated or added.


Log in to reply
 

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