6.4 Linked List 重做

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;
  1. 没有使用 while loop 循环来对整个链表进行操作
  2. check 空指针是对于head.next 来进行check if(next.next == null) return next;
posted @ 2018-06-04 11:26  AugusKong  阅读(120)  评论(0编辑  收藏  举报