首页 > 其他 > 详细

6.4 Linked List 重做

时间:2018-06-04 13:34:07      阅读:204      评论:0      收藏:0      [点我收藏+]
PriorityQueue<ListNode> queue= new PriorityQueue<ListNode>(lists.length,new Comparator<ListNode>(){
            @Override
            public int compare(ListNode o1,ListNode o2){
                if (o1.val<o2.val)
                    return -1;
                else if (o1.val==o2.val)
                    return 0;
                else 
                    return 1;
            }
        });
        
    

错误:
1.不知道如何对PriorityQueue进行声明操作
2.没有在向queue中添加元素之前进行check null的操作

错误:

  1. 接尾巴的时候不知道逻辑,应当声明 p1 = head.next;

    ListNode prev = head;
    ListNode p1 = head.next;
    ListNode curr = p1;
  2. 没有使用 while loop 循环来对整个链表进行操作
  3. check 空指针是对于head.next 来进行check if(next.next == null) return next;

6.4 Linked List 重做

原文:https://www.cnblogs.com/kong-xy/p/9132467.html

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