struct ListNode { int m_nKey; ListNode* next; } ListNode* reverseList(ListNode* pHead) { ListNode* pReversedHead = nullptr; ListNode* pNode = pHead; ListNode* pPrev = nullptr; while(pNode != nullptr){ ListNode* pNext = pNode->next; if(pNext == nullptr) pReversedHead = pNode; pNode->next = pPrev; pPrev = pNode; pNode = pNext; } return pReversedHead; }
//备注:递归实现方式待完善?