Interview Bootcamp
Ask Author
Back to course home

0% completed

Vote For New Content
Approach 2

Eslam Hossam

Oct 17, 2023

For approach 2, what is the difference between using set and using list since the if condition will check if the number is unique or not.

0

0

Comments
Comments
Design Gurus
Design Gurus2 years ago

The set allows us to check if the element exists in it in O(1), whereas, in the case of a list, we have to iterate the whole list to find if the element exists in it or not which is O(n).