Linked Lists - Remove Duplicates
Description:
Linked Lists - Remove Duplicates
Write a RemoveDuplicates() function which takes a list sorted in increasing order and deletes any duplicate nodes from the list. Ideally, the list should only be traversed once. The head of the resulting list should be returned.
var list = 1 -> 2 -> 3 -> 3 -> 4 -> 4 -> 5 -> null
removeDuplicates(list) === 1 -> 2 -> 3 -> 4 -> 5 -> null
If the passed in list is null/None/nil, simply return null.
Note: Your solution is expected to work on long lists. Recursive solutions may fail due to stack size limitations.
The push() and buildOneTwoThree() functions need not be redefined.
Related Kata in order of expected completion (increasing difficulty):
Linked Lists - Push & BuildOneTwoThree
Linked Lists - Length & Count
Linked Lists - Get Nth Node
Linked Lists - Insert Nth Node
Linked Lists - Sorted Insert
Linked Lists - Insert Sort
Linked Lists - Append
Linked Lists - Remove Duplicates
Linked Lists - Move Node
Linked Lists - Move Node In-place
Linked Lists - Alternating Split
Linked Lists - Front Back Split
Linked Lists - Shuffle Merge
Linked Lists - Sorted Merge
Linked Lists - Merge Sort
Linked Lists - Sorted Intersect
Linked Lists - Iterative Reverse
Linked Lists - Recursive Reverse
Inspired by Stanford Professor Nick Parlante's excellent Linked List teachings.
Similar Kata:
Stats:
Created | Aug 23, 2015 |
Published | Aug 23, 2015 |
Warriors Trained | 5435 |
Total Skips | 418 |
Total Code Submissions | 8460 |
Total Times Completed | 2365 |
JavaScript Completions | 991 |
Python Completions | 1210 |
Swift Completions | 215 |
CoffeeScript Completions | 10 |
COBOL Completions | 1 |
Total Stars | 96 |
% of votes with a positive feedback rating | 94% of 364 |
Total "Very Satisfied" Votes | 322 |
Total "Somewhat Satisfied" Votes | 38 |
Total "Not Satisfied" Votes | 4 |