educative.io

Educative

Why not use a set instead of a hash table to check for duplicates in a singly linked list?

Wouldn’t a set work just as well as a hash table?

Hi, @Grace1
Set wouldn’t store data in key-value pairs.

Of course not but what are k/v pairs necessary for here to solve the problem? We are querying the key only.


Course: Data Structures and Algorithms in Python - Learn Interactively
Lesson: Remove Duplicates - Data Structures and Algorithms in Python