LintCode 翻转链表
来源:互联网 发布:2016淘宝日刷千单 编辑:程序博客网 时间:2024/05/20 11:46
翻转一个链表
样例
给出一个链表1->2->3->null,这个翻转后的链表为3->2->1->null
/** * Definition for ListNode. * public class ListNode { * int val; * ListNode next; * ListNode(int val) { * this.val = val; * this.next = null; * } * } */public class Solution { /* * @param head: n * @return: The new head of reversed linked list. */ public ListNode reverse(ListNode head) { if (head==null){ return head; } ListNode p=head; ListNode next=head.next; ListNode pre=new ListNode(0); pre.next=head; while(p!=null){ next=p.next; p.next=pre; pre=p; p=next; } head.next=null; return pre; }}
阅读全文
0 0
- LintCode-翻转链表
- lintcode 翻转链表
- LintCode:翻转链表
- lintcode,翻转链表
- 翻转链表,lintcode
- Lintcode 翻转链表
- LintCode 翻转链表
- 翻转链表-LintCode
- LintCode : 翻转链表
- [Lintcode]翻转链表
- lintcode--翻转链表
- Lintcode翻转链表
- LintCode 翻转链表
- lintcode翻转链表
- LintCode 翻转链表
- Lintcode:翻转链表
- LintCode:翻转链表 II
- 【LintCode】翻转链表 II
- mac下eclipse配置tomcat
- spring集成web socket小demo(demo1)
- # Software-eng lab 2
- 自己 build emacs 24.5
- Postfix 小技巧和故障诊断命令
- LintCode 翻转链表
- 搜索引擎优化中会犯的错
- 功能: 正则表达式应用验证登录(C#学习日记 2017-09-22)
- 禁止在 .NET Framework 中执行用户代码。启用 "clr enabled" 配置选项
- mysql数据库学习(1)
- linux下C实现多线程
- mysql 1118 Row size too large 错误
- rtsp学习
- Canvas实现图片裁剪、移动、放大缩小以及图片的合成