leetcode每日一题-83
public static ListNode deleteDuplicates(ListNode head) {
if(head==null||head.next==null)return head;
ListNode cur=head;
while(cur.next!=null){
if (cur.next.val==cur.val) {
cur.next=cur.next.next;
}else {
cur=cur.next;
}
}
return head;
}
public static ListNode deleteDuplicates(ListNode head) {
if(head==null||head.next==null)return head;
ListNode cur=head;
while(cur.next!=null){
if (cur.next.val==cur.val) {
cur.next=cur.next.next;
}else {
cur=cur.next;
}
}
return head;
}
全部评论
相关推荐
点赞 评论 收藏
分享
点赞 评论 收藏
分享