再删除时,处理下连续相同节点到情况 public ListNode deleteDuplicates (ListNode head) { // write code here if (head == null) { return head; } ListNode curNode = head; while (curNode != null && curNode.next != null) { if (curNode.val == curNode.next.val) { ListNode temp = curNode.next; // 当存在连续相同节点时,删除全部相同节点 while (temp != null && curNode.val == temp.val) { temp = temp.next; } curNode.next = temp; } curNode = curNode.next; } return head; }
点赞

相关推荐

joecii:如果没有工资,那可能没有工资是这家公司最小的问题了
找实习记录
点赞 评论 收藏
分享
MinGW_:直接投那个前端移动端就行,美团前端的岗位一直是叫这个名字的,哪怕是做内部系统只有网页没有移动端的组,招人的岗位也是这个名字
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务