Originally Posted By: Sat
Originally Posted By: jaytea
i can't really think of a reasonable solution that runs in O(n * log(n)). perhaps something involving an initial sort?

yes, eg sort the array, then for each x in the array use binary search to test for the presence of M-x


O(n * log(n))

Isn't O(n) (what jaytea posted) better than that though?