19. Remove Nth Node From End of List
Solutions
Loop twice
- Loop through the list to count the length of this list
- Loop through the list again until meets the (length - n)th node from the beginning Loop once
- Keep two pointer slow and fast, where fast is n+1 step faster than slow.
- When fast reaches to the end, slow is pointing to the correct solution.
PREVIOUSNumber of Islands