题目:删除链表中重复的节点
eg.Input: 1->1->2->3->3 Output: 1->2->3
class Solution {
public ListNode deleteDuplicates(ListNode head) {
if(head==null||head.next==null)
return head;
ListNode l1=head;
ListNode l2=head.next;
while(l2!=null){
if(l1.val!=l2.val){
l1=l1.next;
}
else{
l1.next=l2.next;
}
l2=l2.next;
}
return head;
}
}