https://leetcode-cn.com/problems/fan-zhuan-lian-biao-lcof/
点击查看【bilibili】
# 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"""preNode = NonecurNode = headwhile curNode:# 创建临时变量存储cur的下一位temp = curNode.next# 断开节点curNode.next = preNode# 处理下一位preNode = curNodecurNode = tempreturn preNode
