diff --git a/problems/0035.搜索插入位置.md b/problems/0035.搜索插入位置.md index 593e3fe5..914c2679 100644 --- a/problems/0035.搜索插入位置.md +++ b/problems/0035.搜索插入位置.md @@ -232,7 +232,24 @@ class Solution { } } ``` - +Golang: +```golang +// 第一种二分法 +func searchInsert(nums []int, target int) int { + l, r := 0, len(nums) - 1 + for l <= r{ + m := l + (r - l)/2 + if nums[m] == target{ + return m + }else if nums[m] > target{ + r = m - 1 + }else{ + l = m + 1 + } + } + return r + 1 +} +``` Python: ```python3