The increasing sequence contains some information. The complexity of the violence method for this question is N^2. Another method is to fix the left side and move the right side according to the target. But this is not the traditional method of double pointers. We need to pay attention to the problem that the implicit condition for the smallest printing product is the smallest set on the left. Therefore, the left and right pointer switching method similar to binary search is adopted. coding
define ans vector ;
define left right
while()
sum = a[left] + a[right-1];
if sum== return
if sum> right --;
if < left ++;
return ans;
Summary and reflection
Vectors need to be proficient in using APIs, and they cannot create or insert them.