while(k>j){ int temp=abs(nums[i]+nums[j]+nums[k]-target); if(temp<dif){ dif=temp; ans=nums[i]+nums[j]+nums[k]; } k--; }