set(key, value) - Set or insert the value if the key is not already present
But for the following input
set(2,2) shouldn't be considered because key '2' is already present in the cache with value '1'.
so the value for key '2' in the cache should be '1'.
But m getting
expected should be [1,-1]
set(2,2) overwrites the (2,1) value, it doesn't get ignored. The only thing that gets ignored is when you get(x) when x is not a key in the list. The result of get(2) is the new value, 2.