Reverse Linked List | Problem No. 206 | LeetCode
Reverse a singly linked list.
Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL Solution:
Approach 1: Recursive
ListNode* reverseList(ListNode* head) {
if(head==NULL || head->next==NULL)
return head;
ListNode* prev = reverseList(head->next);
head->next->next=head;
head->next=NULL;
return prev;
}