Leetcode学习笔记:#83. Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.
实现:
public ListNode deleteDuplicates(ListNode head) {
if(head == null || head.next == null)return head;
head.next = deleteDuplicates(head.next);
return head.val == head.next.val ? head.next : head;
}