We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5ed6304 commit 3cc2899Copy full SHA for 3cc2899
Linked_List/2074.Reverse-Nodes-in-Even-Length-Groups/2074.Reverse-Nodes-in-Even-Length-Groups.cpp
@@ -57,14 +57,15 @@ class Solution {
57
58
ListNode* reverseLinkedList(ListNode* head)
59
{
60
- ListNode* h = head;
+ ListNode* cur = head;
61
ListNode* last = NULL;
62
- while (h!=NULL)
+ ListNode* next = NULL;
63
+ while (cur!=NULL)
64
- ListNode* nxt = h->next;
65
- h->next = last;
66
- last = h;
67
- h = nxt;
+ next = cur->next;
+ cur->next = last;
+ last = cur;
68
+ cur = next;
69
}
70
return last;
71
0 commit comments