class Solution { public: vector<int> FindNumbersWithSum(vector<int> array,int sum) { vector<int> res; if(array.size()<2)return res; int min=array[array.size()-1]*array[array.size()-1],first=0,last=array.size()-1; while(first<last) { if(array[first]+array[last]==sum) { if(array[first]*array[last]<min) { if(res.empty()) { res.push_back(array[first]); res.push_back(array[last]); } else{ res[0]=array[first]; res[1]=array[last];} min=res[0]*res[1]; } last--; } while(first<last&&array[first]+array[last]>sum) { last--; if(array[first]+array[last]==sum) { if(array[first]*array[last]<min) { if(res.empty()) { res.push_back(array[first]); res.push_back(array[last]); } else{ res[0]=array[first]; res[1]=array[last];} min=res[0]*res[1]; } last--; } } first++; } return res; } };