首页 > 其他 > 详细

反转链表

时间:2019-11-22 21:17:00      阅读:103      评论:0      收藏:0      [点我收藏+]
package com.imust;

class Node {
    public int value;
    public Node next;

    public Node(int data) {
        this.value = data;
    }
}
public class ReverseList {
    public static void reverseList(Node head) {
        if (head == null || head.next == null)
            return;
        Node pre = null;//先前节点
        Node next = null;//临时节点
        while (head != null) {
            next = head.next;
            head.next = pre;
            pre = head;
            head = next;
        }

    }
}
https://www.bilibili.com/video/av49762694?from=search&seid=8970664744949276024

反转链表

原文:https://www.cnblogs.com/qidi/p/11913874.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!