206. Reverse Linked List
2016-03-01 14:51
113 查看
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ public class Solution { public ListNode reverseList(ListNode head) { if(head==null) return head; ListNode result = null ; ListNode temp = null; while (head!=null) { if (head.next!=null) {temp = head.next; head.next = result; result = head; head = temp;} else { head.next = result; result = head; head = null; } } return result; } }
相关文章推荐
- 通过句柄获取或遍历SysListView32和SysTreeView32控件的数据信息
- 《大型网站技术架构》读书笔记四:瞬时响应之网站的高性能架构
- 一起talk GDB吧(第七回:GDB监视功能)
- hadoop io PART1
- 前端之JavaScript第四天学习(10)-JavaScript-运算符
- android 跨进程通讯 AIDL
- 集合工具类:Collections
- [oracle] 设置PL/SQL Developer 字符集
- Git使用流程
- V-Play 文档翻译 Page
- 利用原生js提升jquery选择器的性能
- java多线程锁种类
- GCC wiki Visibility
- Android注解
- bananapi之system安装
- Android高效加载大图、多图解决方案,有效避免程序OOM
- java对redis的基本使用(Jedis)
- Servlet间的跳转
- Spring MVC 单个文件上传
- Ubuntu上轻松实现PHP扩展