{
  "type": "code_options",
  "author": "csdn.net",
  "source": "solution.md",
  "exercise_id": "417f0b913c0a43d6aed69cf4e2b2411c",
  "keywords": "链表",
  "title": "删除排序链表中的重复元素",
  "desc": [
    {
      "content": "\n<p>存在一个按升序排列的链表，给你这个链表的头节点 <code>head</code> ，请你删除所有重复的元素，使每个元素 <strong>只出现一次</strong> 。</p><p>返回同样按升序排列的结果链表。</p><p> </p><p><strong>示例 1：</strong></p><img alt=\"\" src=\"https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0083.Remove%20Duplicates%20from%20Sorted%20List/images/list1.jpg\" style=\"width: 302px; height: 242px;\" /><pre><strong>输入：</strong>head = [1,1,2]<strong><br />输出：</strong>[1,2]</pre><p><strong>示例 2：</strong></p><img alt=\"\" src=\"https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0083.Remove%20Duplicates%20from%20Sorted%20List/images/list2.jpg\" style=\"width: 542px; height: 222px;\" /><pre><strong>输入：</strong>head = [1,1,2,3,3]<strong><br />输出：</strong>[1,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) {\n\t\tval = x;\n\t}\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\thead.next = deleteDuplicates(head.next);\n\t\tif (head.val == head.next.val)\n\t\t\thead = head.next;\n\t\treturn head;\n\t}\n}",
    "language": "java"
  },
  "node_id": "dailycode-2adfe208aeec4d2fa3eb42cb8361e417",
  "license": "csdn.net",
  "created_at": 1637894161,
  "topic_link": "https://bbs.csdn.net/topics/600470129"
}