zoukankan      html  css  js  c++  java
  • 206 反转链表 python

    206. 反转链表 python

    • 方法一:迭代,边遍历边反转指针
    # 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
            """
            pre = None
            current = head
            while current:
                temp =current.next
                current.next = pre
                pre = current
                current = temp
            return pre
    
    仙衣眠云碧岚袍,一襟潇洒,两袖飘飘。玉墨舒心春酝瓢,行也逍遥,坐也逍遥。
  • 相关阅读:
    spring boot 配置时区差别
    概率期望
    Euler函数与Euler定理
    素数&筛法
    等差子序列
    8.19 T2
    8.19 T1
    量化交易
    挺进

  • 原文地址:https://www.cnblogs.com/max520liuhu/p/11010926.html
Copyright © 2011-2022 走看看