Question: What does the following code snippet do? 7 ListNode* solve (ListNode* head) { 8 ListNodex prev = NULL; 9 if (head == NULL) { 10

What does the following code snippet do? 7 ListNode* solve (ListNode* head) { 8 ListNodex prev = NULL; 9 if (head == NULL) { 10 return head; 11 12 if (head -> next == NULL) { 13 return head; 14 15 ListNode* curr = head -> next; 16 while (head != NULL) K 17 head -> next = prev; 18 prev = head; 19 head = curr; 20 if (curr != NULL) { 21 curr = curr -> next; 22 23 24 return prev; 25 } Returns the linked list after pairwise swapping the elements O Returns the original linked list Returns the linked list after reversing it
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
