{
  "type": "code_options",
  "author": "csdn.net",
  "source": "solution.md",
  "exercise_id": "8ce93ea1bbcc46d3802dac945e1bb600",
  "keywords": "链表,双指针",
  "title": "删除排序链表中的重复元素 II",
  "desc": [
    {
      "content": "\n<p>存在一个按升序排列的链表，给你这个链表的头节点 <code>head</code> ，请你删除链表中所有存在数字重复情况的节点，只保留原始链表中 <strong>没有重复出现</strong><em> </em>的数字。</p><p>返回同样按升序排列的结果链表。</p><p> </p><p><strong>示例 1：</strong></p><img alt=\"\" src=\"https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0082.Remove%20Duplicates%20from%20Sorted%20List%20II/images/linkedlist1.jpg\" style=\"width: 500px; height: 142px;\" /><pre><strong>输入：</strong>head = [1,2,3,3,4,4,5]<strong><br />输出：</strong>[1,2,5]</pre><p><strong>示例 2：</strong></p><img alt=\"\" src=\"https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0082.Remove%20Duplicates%20from%20Sorted%20List%20II/images/linkedlist2.jpg\" style=\"width: 500px; height: 205px;\" /><pre><strong>输入：</strong>head = [1,1,1,2,3]<strong><br />输出：</strong>[2,3]</pre><p> </p><p><strong>提示：</strong></p><ul>\t<li>链表中节点数目在范围 <code>[0, 300]</code> 内</li>\t<li><code>-100 <= Node.val <= 100</code></li>\t<li>题目数据保证链表已经按升序排列</li></ul>",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "java"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "java"
      }
    ],
    [
      {
        "content": "",
        "language": "java"
      }
    ],
    [
      {
        "content": "",
        "language": "java"
      }
    ]
  ],
  "template": {
    "content": "public class ListNode {\n\tint val;\n\tListNode next;\n\tListNode(int x) { val = x; }\n}\nclass Solution {\n\tpublic ListNode deleteDuplicates(ListNode head) {\n\t\tif (head == null || head.next == null) {\n\t\t\treturn head;\n\t\t}\n\t\tListNode next = head.next;\n\t\tif (head.val == next.val) {\n\t\t\twhile (next != null && head.val == next.val) {\n\t\t\t\tnext = next.next;\n\t\t\t}\n\t\t\thead = deleteDuplicates(next);\n\t\t} else {\n\t\t\thead.next = deleteDuplicates(next);\n\t\t}\n\t\treturn head;\n\t}\n}",
    "language": "java"
  },
  "node_id": "dailycode-6007336fac224f659d45e9b3829c6726",
  "license": "csdn.net",
  "created_at": 1637894158,
  "topic_link": "https://bbs.csdn.net/topics/600470128"
}