#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time: 2019/3/19
# @Author: xfLi
# The file...
# 链表头插法
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
def reverseList(head):
if not head: return head
cur = head
pre = None
while cur is not None:
temp = cur.next
cur.next = pre
pre = cur
cur = temp
return pre
【LeetCode】206.反转链表
猜你喜欢
转载自blog.csdn.net/qq_30159015/article/details/88667764
今日推荐
周排行