网址:https://leetcode.com/problems/reverse-linked-list/

直接参考92:https://www.cnblogs.com/tornado549/p/10639756.html

/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* reverseList(ListNode* head)
{
if(!head)
return NULL;
ListNode* a = NULL;
ListNode* b = head;
ListNode* c = b->next;
while(c)
{
b->next = a;
a = b;
b = c;
c = c->next;
}
b->next = a;
return b;
}
};

91. Reverse Linked List 反转链表的更多相关文章

  1. [LeetCode] 206. Reverse Linked List ☆(反转链表)

    Reverse Linked List 描述 反转一个单链表. 示例: 输入: 1->2->3->4->5->NULL    输出: 5->4->3-> ...

  2. [leetcode]206. Reverse Linked List反转链表

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

  3. 206 Reverse Linked List 反转链表

    反转一个单链表.进阶:链表可以迭代或递归地反转.你能否两个都实现一遍?详见:https://leetcode.com/problems/reverse-linked-list/description/ ...

  4. LeetCode206. Reverse Linked List(反转链表)

    题目链接:https://leetcode.com/problems/reverse-linked-list/ 方法一:迭代反转 https://blog.csdn.net/qq_17550379/a ...

  5. [LeetCode] 206. Reverse Linked List 反向链表

    Reverse a singly linked list. Hint: A linked list can be reversed either iteratively or recursively. ...

  6. [LeetCode] Reverse Linked List 倒置链表

    Reverse a singly linked list. click to show more hints. Hint: A linked list can be reversed either i ...

  7. [LintCode] Reverse Linked List 倒置链表

    Reverse a linked list. Have you met this question in a real interview? Yes Example For linked list 1 ...

  8. LeetCode 206. Reverse Linked List倒置链表 C++

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

  9. [LeetCode] 92. Reverse Linked List II 反向链表II

    Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1-> ...

随机推荐

  1. Linux Input子系统

    先贴代码: //input.c int input_register_handler(struct input_handler *handler) { //此处省略很多代码 list_for_each ...

  2. Spring中的事务操作

    事务的特性 原子性:强调事务的不可分割. 一致性:事务的执行的前后数据的完整性保持一致. 隔离性:一个事务执行的过程中,不应该受到其他事务的干扰. 持久性:事务一旦结束,数据就持久化到数据库. 如果不 ...

  3. Java学习之路-Hessian学习

    Hessian是基于HTTP的轻量级远程服务解决方案,Hessian像Rmi一样,使用二进制消息进行客户端和服务器端交互.但与其他二进制远程调用技术(例如Rmi)不同的是,它的二进制消息可以移植其他非 ...

  4. OCP-第三节课.md

    一. dataguard  stream  字节流技术: 二. 突然断电:触发实例恢复过程: 三. 宕机:赔钱 四. Redis.MQ(消息中间件.队列管理器.缓存)(内存数据库) 五. IBM MQ ...

  5. 快学Scala 第6章 对象 - 练习

    1. 编写一个Conversions对象,加入inchesToCentimeters.gallonsToLiters和milesToKilometers方法. object Conversions { ...

  6. 退出unity运行

    public void GetExit()//退出运行 { #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false;//用于退 ...

  7. python_json序列化和反序列化

    序列化 import json dic = {'} print(json.dumps(dic)) 反序列化;json.loads() dic = {'} print(json.dumps(dic)) ...

  8. Linux基础命令---accept/reject 允许拒绝发送打印请求

    accept accept指令用来设置允许向目标打印机发送打印任务. 此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.Fedora.   1.语法      cupsaccept ...

  9. Python+OpenCV图像处理(十五)—— 圆检测

    简介: 1.霍夫圆变换的基本原理和霍夫线变换原理类似,只是点对应的二维极径.极角空间被三维的圆心和半径空间取代.在标准霍夫圆变换中,原图像的边缘图像的任意点对应的经过这个点的所有可能圆在三维空间用圆心 ...

  10. 在oracle中如何把前台传过来的日期字符串转换成正确格式

    insert into ibill_sys_version(versionId,productCode,versionCode,versionDesc,versionUrl, upgradeWay,u ...