Implementation for nth last element and reversing a singly linked list.