Don’t use label in hash map. Rather use type RandomListNode for both keys and values.
Just an advice: Don't use label in hash map
Nothing is specified in problem statement regarding duplicates, so best practice would be to not use label as your key.
theJediCode
#6
Because label
can be duplicated, so when you’ll be assigning a RandomListNode
to some label
that is duplicated, it will override the previous value in that label
, since keys can’t be duplicated in a map, they are simply overwritten by the newer value.