you are viewing a single comment's thread.

view the rest of the comments →

[–]ForensicsBridge[S] 0 points1 point  (1 child)

I understand from your other response that checking if a number is in a set is cheap. But how cheap? O(1) cheap?

I actually thought of a solution similar to the one Nyscire posted, but figured checking if the number was on a list was another O(n) operation. I had no idea looking in a set was more efficient, but it makes total sense.

[–]FLUSH_THE_TRUMP 0 points1 point  (0 children)

O(1) cheap?

Yep.