Remove Nth Node From End of List

 

19. Remove Nth Node From End of List

Solutions

Loop twice

  1. Loop through the list to count the length of this list
  2. Loop through the list again until meets the (length - n)th node from the beginning Loop once
  3. Keep two pointer slow and fast, where fast is n+1 step faster than slow.
  4. When fast reaches to the end, slow is pointing to the correct solution.