Leetcode 19. Remove Nth Node From End of List
We are using a hashmap or dictionary to maintain indexes of node as we traverse them, as soon as we finish traversing we get the nth node from the back by subtracting it from the last node + 1, +1 as we move ahead of the last node and reach null see code to clarify this little thing, we make the pointer of the n-1’th node pointing to n+1’th node.
|
|