刷题 | 关于链表
/* struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { } };*/ class Solution { public: ListNode* ReverseList(ListNode* pHead) { ListNode *newhead=NULL; ListNode *node; //头插法 while(pHead!=NULL){ node=pHead; pHead=pHead->next;//分离头结点 node->next=newhead;//头插法 newhead=node; } return newhead; } };