Link list algorithm to find pairs adding up to 10
问题 Can you suggest an algorithm that find all pairs of nodes in a link list that add up to 10. I came up with the following. Algorithm: Compare each node, starting with the second node, with each node starting from the head node till the previous node (previous to the current node being compared) and report all such pairs. I think this algorithm should work however its certainly not the most efficient one having a complexity of O(n2). Can anyone hint at a solution which is more efficient