标签:code one init coding reverse ret val nod sel
1 # -*- coding:utf-8 -*- 2 # class ListNode: 3 # def __init__(self, x): 4 # self.val = x 5 # self.next = None 6 class Solution: 7 # 返回ListNode 8 def ReverseList(self, pHead): 9 if pHead == None: 10 return None 11 head = pHead 12 nextnode = pHead.next 13 t = ListNode(0) 14 while head: 15 head.next = t.next 16 t.next = head 17 head = nextnode 18 if nextnode != None: 19 nextnode = nextnode.next 20 return t.next 21 # write code here
标签:code one init coding reverse ret val nod sel
原文地址:https://www.cnblogs.com/asenyang/p/11013119.html