反转链表
来源:互联网 发布:承兑汇票 知乎 编辑:程序博客网 时间:2024/06/06 10:06
剑指offer No.16,前边逆序输出链表的那题就可以将链表反转后,直接输出就行,当时是用栈实现的,现在算是圆满了
package com.zjy.sword2offer;public class ReverseList {public static ListNode reverseList(ListNode head){if(head==null)return null;ListNode pre = null;ListNode current = head;while(current!=null){ListNode next = current.next;if(next==null)head = current;current.next = pre;pre = current;current = next;}return head;}public static void main(String[] args) {// TODO Auto-generated method stub}}
0 0
- 链表反转
- 反转链表
- 单向链表反转
- 链表反转:
- 链表的反转
- 链表反转
- 反转单向链表
- 链表反转
- 单向链表反转
- 单向链表反转
- 链表的反转
- 链表反转
- 反转链表
- 链表反转
- 链表反转
- 链表反转
- 链表反转
- 链表的反转
- Oracle拉出在sqlserver建表的语句
- [Unity3d][NGUI]打包NGUI预制件成Assetbundle 两种思路.
- three.js入门5——2014.5.28高亮显示
- Activity生命周期
- MFC如何给控件设置字体
- 反转链表
- VC禁止在任务管理器中结束本进程
- Managing the Activity Lifecycle
- Activity 生命周期
- 安装Ubuntu 14.04后要做的5件事情
- SSI事务问题
- 2014-5-28任务完成情况
- 为什么 PHPer 应当学习 Golang(转)
- 排序算法之冒泡排序