Intuition & Algorithm
Remove the last k nodes before the head node.
Code
1 | /** |
Complexity
Time Complexity: There are two for loop here, cost $O(n)$ time to traverse the lsit.
Space Complexity: $O(1)$
Go for it.
Remove the last k nodes before the head node.
1 | /** |
Time Complexity: There are two for loop here, cost $O(n)$ time to traverse the lsit.
Space Complexity: $O(1)$