Python反转链表
# -*- coding:utf-8 -*- # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def ReverseList(self, pHead): if pHead is None: return last=None while pHead is not None: tmp=pHead.next pHead.next=last last=pHead pHead=tmp return last
浙公网安备 33010602011771号