Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • Excellent thanks. I've found in Obj-C I can use NSMutableSet and the intersectSet method which is what you are doing here in python. Thanks Commented Feb 23, 2015 at 13:11
  • 1
    Set intersection works in O(n^2) Commented Feb 23, 2015 at 13:28
  • @malt, only a very naive implementation. If testing for set membership is O(1), which most implementations are, then you just have to loop through the smaller set and test each member for membership in the other set. Commented Feb 23, 2015 at 14:37
  • And how would you test for set membership in O(1) in the worst case? Commented Feb 23, 2015 at 14:44