Remove Nth Node from the End of a Linked List

Given a singly linked list, write a code to remove nth node from the end of a linked list. In this problem, you can assume the value of n is always valid.

For example –

In this example, the input linked list has four nodes and we have to remove 2nd node from the end.

Input –

15 -> 9 -> 8 -> 5 -> NULL , N = 2

After removing second node (node whose value is 8) from the end, the output is

15 -> 9 -> 5 -> NULL