[LeetCode]83. Remove Duplicates from Sorted List(Easy)

Description:

Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well.

Example 1:

Input: head = [1,1,2,3,3]
Output: [1,2,3]

Solution 1:

Time complexity O(N). We would need both prev and curNode. If prev’s value is equivalent to curNode’s value, set prev.next to curNode.next. Otherwise, move prev to prev.next.

--

--

--

Be Effective and Optimize for Learning

Love podcasts or audiobooks? Learn on the go with our new app.

Advanced Concepts of JavaScript

https://www.b7b7ha.xyz/2022/03/1000000-with-google-in-6-months-and-more.html

What’s New in TypeScript 4.0

Sign In with Apple using JavaScript

Practical Angular: The Most Impactful RxJs Best Practice Tip Of All Time

18 Drag And Drop For Web Development

Code-Chatter Case Study

JavaScript Weekly Issue 17

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sherlock Chiou

Sherlock Chiou

Be Effective and Optimize for Learning

More from Medium

Dan Ariely on decision making

Benefits of Nature on Artists (and not only!)

Understanding ANS coding through examples

x: 8 9 10 11 12 13 14 15, S: B A C C B A A B, y: 3 5 2 3 4 3 4 5, k: 2 1 2 2 1 2 1 1

Big Business Support Interviews