class Solution {
public int[] twoSum(int[] nums, int target) {
int l=0;
int r=nums.length-1;
while(l<r){
long temp=(long)nums[l]+nums[r];
if(temp==target){
return new int[]{nums[l],nums[r]};
}else if(temp>target){
r--;
}else{
l++;
}
}
return new int[]{};
}
}