Refactor
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "s0025_reverse_nodes_in_k-group.hpp"
|
||||
|
||||
// 翻转一个子链表,并且返回新的头与尾
|
||||
pair<ListNode*, ListNode*> myReverse(ListNode* head, ListNode* tail) {
|
||||
pair<ListNode*, ListNode*> S0025::myReverse(ListNode* head, ListNode* tail) {
|
||||
ListNode* prev = tail->next;
|
||||
ListNode* p = head;
|
||||
while (prev != tail) {
|
||||
@@ -13,7 +13,7 @@ pair<ListNode*, ListNode*> myReverse(ListNode* head, ListNode* tail) {
|
||||
return {tail, head};
|
||||
}
|
||||
|
||||
ListNode* Solution::reverseKGroup(ListNode* head, int k) {
|
||||
ListNode* S0025::reverseKGroup(ListNode* head, int k) {
|
||||
ListNode* hair = new ListNode(0);
|
||||
hair->next = head;
|
||||
ListNode* pre = hair;
|
||||
|
||||
Reference in New Issue
Block a user