Algs4-1.3.25编写一个方法insertAfter()

1.3.25编写一个方法insertAfter(),接受两个链表结点作为通用数,将第二个结点插入链表并使之成为第一个结点的后续结点(如果两个参数为空则什么也不做)。
答:
public  insertAfter(Node x,Node y)
{
    if(!(x==null || y==null))
        y.next=x.next;
        x.next=y;
 }

猜你喜欢

转载自www.cnblogs.com/longjin2018/p/9849566.html