Pick the tightest time complexity, including the initial sort.
functionhasThreeSum(nums, target){ nums.sort((a, b)=> a - b)for(let i =0; i < nums.length-2; i++){let left = i +1let right = nums.length-1while(left < right){const sum = nums[i]+ nums[left]+ nums[right]if(sum === target)returntrueif(sum < target) left++else right--}}returnfalse}