/**
* @param {number[]} nums
* @param {number} target
* @return {number[]}
*/
var findNumbersWithSum = function(nums, target) {
let l = 0, r = nums.length - 1;
nums.sort((a,b) => a - b);
while(l < r) {
if(nums[l] + nums[r] === target) return [nums[l], nums[r]];
else if(nums[l] + nums[r] > target) r--;
else l ++;
}
return [];
};