You are viewing a single comment's thread. Return to all comments →
Want elegance?
Can be done with a one-liner in python:
len(set(a) & set(x + k for x in a))
Where a is the array of numbers. Runs in O(N) to boot(sorting is O(nlogn))
Seems like cookies are disabled on this browser, please enable them to open this website
Pairs
You are viewing a single comment's thread. Return to all comments →
Want elegance?
Can be done with a one-liner in python:
Where a is the array of numbers. Runs in O(N) to boot(sorting is O(nlogn))