35. 搜索插入位置
- 题号:35
- 来源:LeetCode
- 难度:简单
- 标签:
二分数组 - 语言:TypeScript
- 解法:1 个
- 作者:lmliheng
- 最近更新:2026-09-27
TypeScript · O(log n) 时间 · O(1) 空间 · 更新于 2026-09-27
lowerBound 二分定位插入下标,注释已写明
typescript
/**
* @difficulty easy
* @tags 二分,数组
* @time O(log n)
* @space O(1)
* @note lowerBound 二分定位插入下标,注释已写明
* @35. 搜索插入位置
*/
import { lowerBound } from "../算法/二分查找/二分查找.js";
/**
*
* 时间复杂度log(n)
*/
function searchInsert(nums: number[], target: number) {
return lowerBound((mid) => nums[mid] >= target, 0, nums.length)
};在 GitHub 上查看题目所在目录:lmliheng/algorithm