List Linked List Note [leetcode] 83. Remove Duplicates from Sorted List sorted linked to weight (weight to have heavy)

Q: In sweeping the entire list when in the end when to use while (! Cur = null)  When using while (cur.next = null!) It?

In [leetcode] 83. Remove Duplicates from Sorted List sorted linked to weight (with a weight to weight) and [leetcode] 82. Remove Duplicates from Sorted List II sorted linked to weight (light to heavy deleted) Example

To list 1-> 1-> null A Case Study

1. If the meaning of the questions required to heavy weight, you will need to retain the element cur after the de-emphasis, stopped when cur.next == null, because the cur must be retained

2. If the meaning of the questions require deduplication light, you will need to delete the element of light to heavy cur, cur == stopped when it null, because the cur must be deleted

 

Q: What is the time to use   ListNode dummy = new new ListNode (-1)

As far as the operation of a given list ListNode head (including delete, move, etc.), should be given in advance to use the dummy chain hooked up ListNode head, preventing subsequent operation, changes caused ListNode head information list can not be found head knot of problems!

 

Guess you like

Origin www.cnblogs.com/liuliu5151/p/10958283.html