DEV Community

loading...

Discussion on: Daily Coding Problem #1

Collapse
simplyz profile image
Zulhaj Choudhury

Hi Ivan,

I'm trying to understand this better.
How come you didn't do numbers.contains() instead of set.contains()? Does using the original list of numbers violate one pass?

Collapse
cwetanow profile image
Ivan Author

Because numbers.contains() is a list and to see if it contains the element would loop through the whole list (basically O(n). That makes the solution to have two nested loops and going full O(n^2)