Question DSA-LL-0080
HardHow do you remove duplicate values from an unsorted singly linked list in O(n) expected time?
- A.
Sort the list first
- B.
Reverse the list
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Linked Lists question
How do you remove duplicate values from an unsorted singly linked list in O(n) expected time?
Sort the list first
Reverse the list
Sign up free to see the answer and a step-by-step explanation.
Keep a hash set of values seen so far and unlink any node whose value is already in it
Compare every pair of nodes