LeetCode subject
Given a sort list , Delete all nodes with duplicate numbers , Keep only the original linked list No recurrence The number of .
Example :
input : 1->2->3->3->4->4->5
output : 1->2->5
Algorithmic idea
1. Create a virtual node , Connect all non repeating nodes to the back
2. definition cur Ergodic single chain table , Judge whether the number of current node and next node is the same
3. Return to new single chain table
class Solution { public ListNode deleteDuplicates(ListNode head) { if(head==
null||head.next==null){ return head; } ListNode node=new ListNode(-1); ListNode
tmp=node; ListNode cur=head; while(cur!=null){ if(cur.next!=null&&cur.val==cur.
next.val){ while(cur.next!=null&&cur.val==cur.next.val){ cur=cur.next; } cur=cur
.next; }else{ tmp.next=cur; cur=cur.next; tmp=tmp.next; } } tmp.next=null;
return node.next; } }

©2019-2020 Toolsou All rights reserved,
python obtain excel A column or row of data python read , write in txt Text content Huawei Mate 40 Pro+ 5G exposure : Leica film lens , Ceramic body python in switch_to_alert Usage of about Bellman-Ford Personal understanding of algorithms Programmer and architect Hua Shan Vue Development tips Python realization switch method ( Essence )2020 year 7 month 13 day Wechat applet Inter communication page org.postgresql.util.PSQLException Processing records