import java.util.ArrayList;java
public class Solution {code
public ArrayList<Integer> FindNumbersWithSum(int [] array,int sum) { ArrayList<Integer> list = new ArrayList<Integer>(); int len=array.length-1; if(len<2) return list; int left=0; int right=len; int total= array[left]+array[right]; while(left<right){ while(total<sum&&left<right) total=array[right]+array[++left]; while(total>sum&&right>left) total=array[left]+array[--right]; if(total==sum) break; } if(left==right) return list; list.add(array[left]); list.add(array[right]); return list; }
}it