链表之删除双链表倒数第K个节点
题目:
链表之删除双链表倒数第K个节点
思路:
之前写过 http://blog.csdn.net/u011068702/article/details/50280099(链表之删除单链表倒数第K个节点),思路是一样的,如果不知道,你可以参考下
代码实现:
package com.chenyu.zuo.linkedList;import com.chenyu.zuo.linkedList.PrintCommonPart.Node;public class RemoveLastNodeDoubleLinked {public static class DoubleNode{//内部类public DoubleNode next;public int value;public DoubleNode last;public DoubleNode(int value){this.value=value;} }public DoubleNode removeLastNodeDoubleLinked(DoubleNode head,int lastLenth){if(head==null || lastLenth<1){ //当链表为空或者倒数第几个的数组小于1就返回头结点