# 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):
        if(head==None):return None
        if(head.next==None):return head
       
        # pre=head
        # p=head.next
        # pre.next=None
        # nxt=None
        new_head=None
        while head:
            p=head
            head=head.next
            p.next=new_head
            new_head=p
        return new_head

【leetcode❤python】206. Reverse Linked List的更多相关文章

  1. [LeetCode&Python] Problem 206. Reverse Linked List

    Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->4-> ...

  2. 【leetcode❤python】 7. Reverse Integer

    #-*- coding: UTF-8 -*-#2147483648#在32位操作系统中,由于是二进制,#其能最大存储的数据是1111111111111111111111111111111.#正因为此, ...

  3. 【leetcode❤python】 190. Reverse Bits

    #-*- coding: UTF-8 -*- class Solution:    # @param n, an integer    # @return an integer    def reve ...

  4. 【leetcode❤python】 203. Remove Linked List Elements

    #-*- coding: UTF-8 -*- # Definition for singly-linked list.# class ListNode(object):#     def __init ...

  5. 【leetcode❤python】 234. Palindrome Linked List

    #-*- coding: UTF-8 -*-class Solution(object):    def isPalindrome(self, head):        ""&q ...

  6. 【LeetCode】206. Reverse Linked List (2 solutions)

    Reverse Linked List Reverse a singly linked list. click to show more hints. Hint: A linked list can ...

  7. 【leetcode❤python】Sum Of Two Number

    #-*- coding: UTF-8 -*- #既然不能使用加法和减法,那么就用位操作.下面以计算5+4的例子说明如何用位操作实现加法:#1. 用二进制表示两个加数,a=5=0101,b=4=0100 ...

  8. 【LeetCode】206. Reverse Linked List 解题报告(Python&C++&java)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 迭代 递归 日期 [LeetCode] 题目地址:h ...

  9. 【一天一道LeetCode】#206. Reverse Linked List

    一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Reverse ...

随机推荐

  1. 远程mysql服务器无法连接解决方案

    错误现象:Habon被拒绝. 远程服务器无法连接从两个方面看 1.是否能ping通远程服务器 windows下查看防火墙是否已关闭 linux下查看iptables等 2.数据库是否有开用户管理权限 ...

  2. C# 文件读取(二)

    将我的电脑中的文件夹信息显示到TreeView控件上. 方法很多种,下面这种方法添加了我的文档. public partial class Form1 : Form { public Form1() ...

  3. 为centos添加额外的源

    使用这个命令: yum install epel-release

  4. [转载]Emmet使用手册

    转载地址:  http://www.w3cplus.com/tools/emmet-cheat-sheet.html 介绍 Emmet (前身为 Zen Coding) 是一个能大幅度提高前端开发效率 ...

  5. 下拉框分组显示optgroup

    <select> <optgroup label="语言"> <option>中文</option> <option>英 ...

  6. Openstack的error僵尸实例的解决办法

    在我们对集群环境进行各种调整的情况下,很容易产生一些僵尸实例. 僵尸实例主要是没有该主机,但是在dashboard上,数据库中存在,解决办法网络上有的人给出了繁杂的修改数据库的方法,其实按照下面的命令 ...

  7. linux设备驱动归纳总结(三):3.设备驱动面向对象思想和lseek的实现【转】

    本文转自自:http://blog.chinaunix.net/uid-25014876-id-59418.html linux设备驱动归纳总结(三):3.设备驱动面向对象思想和lseek的实现 一. ...

  8. DLL:加载错误

    一:试图加载格式不正确的程序 把目标平台Any CPU 设置为X86:

  9. linux内核栈用户栈切换【转】

    转自:http://www.kerneltravel.net/kernel-book/%E7%AC%AC%E5%9B%9B%E7%AB%A0%20%E8%BF%9B%E7%A8%8B%E6%8F%8F ...

  10. oracle 创建表空间用户

    1.创建普通表空间和用户 //创建临时表空间create temporary tablespace oa_temptempfile 'D:\app\Administrator\oradata\orcl ...