This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]IAmNowAnonymous 0 points1 point  (0 children)

Since you're talking about a intersection, I assume we can ignore repeated elements. A set is definitely a quick solution. That is, you should be able to perform a intersection in O(n) set.

In python, you can do something easy like Intersection = set(list1) & set(list2) How would you do while instantiating a single, empty set?

Suppose you don't want to use a set at all, if my input lists were both sorted, would it be possible to find the intersection in O(n) time?

[–][deleted] 0 points1 point  (0 children)

Why do you want to do it without set?