描述
输入一个链表,反转链表后,输出新链表的表头。
输入{1,2,3}
输出{3,2,1}
class Solution: def ReverseList(self, pHead): if pHead is None or pHead.next is None: return pHead pnext = None pre = None while(pHead is not None): pnext = pHead.next pHead.next = pre pre = pHead pHead = pnext return pre