6 kyu

Linked Lists - Remove Duplicates

991 of 2,365JDeBolt

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.

Linked Lists
Data Structures
Fundamentals

Similar Kata:

Stats:

CreatedAug 23, 2015
PublishedAug 23, 2015
Warriors Trained5435
Total Skips418
Total Code Submissions8460
Total Times Completed2365
JavaScript Completions991
Python Completions1210
Swift Completions215
CoffeeScript Completions10
COBOL Completions1
Total Stars96
% of votes with a positive feedback rating94% of 364
Total "Very Satisfied" Votes322
Total "Somewhat Satisfied" Votes38
Total "Not Satisfied" Votes4
Ad
Contributors
  • JDeBolt Avatar
  • CIS 122 Avatar
  • Bubbler Avatar
  • FArekkusu Avatar
  • akar-0 Avatar
  • LosBlobbos Avatar
Ad