2 ms·
> add each node to the set if it is not present, O(1). Not in space complexity. > A bit more aggressive, check System.Runtime.heapSize() calculate how many no
by saagarjha 7y ago
> add each node to the set if it is not present, O(1).
Not in space complexity.
> A bit more aggressive, check System.Runtime.heapSize() calculate how many nodes can fit in the heap, and subtract 1 for each element visited.
This one will take quite a while…
> recognize that pointers are always powers of 2, so go ahead and tag that pointer
They're not always, and this is also technically uses extra space.