【发布时间】:2014-07-08 19:41:40
【问题描述】:
练习软件开发人员面试,但被算法问题困住了。
Given two sets of unsorted integers with array of length m and other of
length n and where m < n find an efficient algorithm to determine if
the sets are disjoint. I've found solutions in O(nm) time, but haven't
found any that are more efficient than this, such as in O(n log m) time.
【问题讨论】:
-
O(n log m) 不会比 O(n) 慢吗?
-
McLovin 打败了我。O(n)
-
O(n+m) 是你能做的最好的。此外,O(n) 比 O(n log m) 更有效
-
我的错,应该是“O(nm) time”!
-
哈希表有用吗?