def reverse(self):
pre,cur=self.nil,self.nil.next
while(cur!=self.nil):
next=cur.next
cur.next=pre
pre,cur=cur,next
self.nil.next=pre
chap10 单链表倒置
最新推荐文章于 2022-06-11 00:41:04 发布
def reverse(self):
pre,cur=self.nil,self.nil.next
while(cur!=self.nil):
next=cur.next
cur.next=pre
pre,cur=cur,next
self.nil.next=pre