function searchInsert(nums: number[], target: number): number { let l = 0; let r = nums.length - 1; while(l <= r){ let mid = l + Math.floor((r-l)/2); if(nums[mid] == target){ return mid }else if(nums[mid]<target){ l = mid + 1; }else if(nums[mid]>target){ r = mid -1 } } }; console.log(searchInsert([1,3,5,6], 2))