解法:Two Sum 双指针
Python 代码
N, V = map(int, input().split())
nums = list(map(int, input().split()))
nums.sort()
l, r = 0, N - 1
while l < r:
twosum = nums[l] + nums[r]
if twosum == V:
break
elif twosum < V:
l += 1
else:
r -= 1
if l < r: print(nums[l], nums[r])
else: print('No Solution')