API to reverse a singly linked list