Walk through capacity = .
put(1,1): List is [1]. Map: {1: node1}.
put(2,2): List is [2, 1]. Node 2 is at the head (most recent). Map: {1: node1, 2: node2}.
get(1): Found in map. Move node 1 to head. List becomes [1, 2]. Return 1.
put(3,3): Cache is full. Evict the tail, which is node 2. Remove key 2 from map. Insert node 3 at head. List: [3, 1]. Map: {1: node1, 3: node3}.
get(2): Not in map. Return -1.
Every operation touches the hash map ( lookup) and the linked list ( move/remove). That's time per operation.
You store at most entries in the map and list, so space where is capacity.