deno.land / x / masx200_leetcode_test@10.6.5 / search-insert-position / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
export default function searchInsert(nums: number[], target: number): number { const n = nums.length; let left = 0, right = n - 1, ans = n; while (left <= right) { const mid = ((right - left) >> 1) + left; if (target <= nums[mid]) { ans = mid; right = mid - 1; } else { left = mid + 1; } } return ans;}
masx200_leetcode_test

Version Info

Tagged at
2 years ago