[leetcode206]Reverse Linked List

xiaoxiao2021-02-28  73

# Definition for singly-linked list. # class ListNode(object): #     def __init__(self, x): #         self.val = x #         self.next = None class Solution(object):     def reverseList(self, head):         """         :type head: ListNode         :rtype: ListNode         """         prev=None         while head :             tmp=head.next             head.next=prev             prev=head             head=tmp         return prev
转载请注明原文地址: https://www.6miu.com/read-63028.html

最新回复(0)