最近在牛客网上刷题,遇见这样一道:
一开始我是这样写的:
ListNode* reverseKGroup(ListNode* head, int k) {
ListNode* pin = head;
ListNode* tempHead = head;
ListNode* tempRear = nullptr;
ListNode* lastRear = nullptr;
stack<ListNode*> nodestack;
for(int i=0;i<k-1;i++){
if(pin==nullptr){