Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ea7312c

Browse files
Improvement
Signed-off-by: begeekmyfriend <begeekmyfriend@gmail.com>
1 parent 0d16d6e commit ea7312c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

‎0025_reverse_nodes_in_k_group/reverse_nodes.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ static struct ListNode* reverseKGroup(struct ListNode* head, int k)
1414
dummy.next = head;
1515
for (; head != NULL; head = head->next) {
1616
if (++len % k == 0) {
17-
/* t always the original first one */
18-
struct ListNode *t = prev->next;
17+
/* p always the original first one */
18+
struct ListNode *p = prev->next;
1919
/* loop condition implicits the final state */
2020
while (prev->next != head) {
2121
/* the new segment head */
22-
struct ListNode *h = t->next;
22+
struct ListNode *q = p->next;
2323
/* deletion */
24-
t->next = h->next;
24+
p->next = q->next;
2525
/* insertion */
26-
h->next = prev->next;
27-
prev->next = h;
26+
q->next = prev->next;
27+
prev->next = q;
2828
}
2929
/* For iteration */
30-
prev = t;
31-
head = t;
30+
prev = p;
31+
head = p;
3232
}
3333
}
3434
return dummy.next;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /