/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode() {}
* ListNode(int val) { this.val = val; }
* ListNode(int val, ListNode next) { this.val = val; this.next = next; }
* }
*/
class Solution {
public ListNode deleteDuplicates(ListNode head) {
if(head==null||head.next==null){
return head;
}
head.next=deleteDuplicates(head.next);
if(head.val==head.next.val)
head=head.next;
return head;
}
}
83. 删除排序链表中的重复元素 Java版
最新推荐文章于 2024-07-27 13:31:57 发布