代码能力,for循环
class Solution { public: ListNode* ReverseList(ListNode* pHead) { if(pHead == NULL || pHead->next == NULL){ return pHead;} ListNode *p=NULL; for(p;pHead;swap(p,pHead)){ swap(pHead->next,p); } return p; } };
代码能力,for循环
class Solution { public: ListNode* ReverseList(ListNode* pHead) { if(pHead == NULL || pHead->next == NULL){ return pHead;} ListNode *p=NULL; for(p;pHead;swap(p,pHead)){ swap(pHead->next,p); } return p; } };