How can I write an algorithm to check if the sum of any two numbers in an array/list matches a given number with a complexity of nlogn?
nlogn
I'm sure there's a better way, but here's an idea:
Both these operations are O(n log n).
O(n log n)