class(object): def__init__(self, x): self.val = x self.next = None
classSolution(object): defreverseList(self, head): """ :type head: ListNode :rtype: ListNode """ last = None while head: next = head.next head.next = last last = head head = next return last
近期评论