mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-13 14:57:08 +00:00
24 lines
1.1 KiB
Markdown
24 lines
1.1 KiB
Markdown
<h2><a href="https://leetcode.com/problems/remove-duplicates-from-sorted-list/">83. Remove Duplicates from Sorted List</a></h2><h3>Easy</h3><hr><div><p>Given the <code>head</code> of a sorted linked list, <em>delete all duplicates such that each element appears only once</em>. Return <em>the linked list <strong>sorted</strong> as well</em>.</p>
|
|
|
|
<p> </p>
|
|
<p><strong class="example">Example 1:</strong></p>
|
|
<img alt="" src="https://assets.leetcode.com/uploads/2021/01/04/list1.jpg" style="width: 302px; height: 242px;">
|
|
<pre><strong>Input:</strong> head = [1,1,2]
|
|
<strong>Output:</strong> [1,2]
|
|
</pre>
|
|
|
|
<p><strong class="example">Example 2:</strong></p>
|
|
<img alt="" src="https://assets.leetcode.com/uploads/2021/01/04/list2.jpg" style="width: 542px; height: 222px;">
|
|
<pre><strong>Input:</strong> head = [1,1,2,3,3]
|
|
<strong>Output:</strong> [1,2,3]
|
|
</pre>
|
|
|
|
<p> </p>
|
|
<p><strong>Constraints:</strong></p>
|
|
|
|
<ul>
|
|
<li>The number of nodes in the list is in the range <code>[0, 300]</code>.</li>
|
|
<li><code>-100 <= Node.val <= 100</code></li>
|
|
<li>The list is guaranteed to be <strong>sorted</strong> in ascending order.</li>
|
|
</ul>
|
|
</div> |