Skip to content

Commit

Permalink
Create 0035-search-insert-position.go
Browse files Browse the repository at this point in the history
  • Loading branch information
AP-Repositories authored Jan 1, 2023
1 parent 0cb22b5 commit d4d53fd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions go/0035-search-insert-position.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
func searchInsert(nums []int, target int) int {
low, high := 0, len(nums)
for low < high {
mid := low + (high - low)/2
if target > nums[mid] {
low = mid + 1
} else {
high = mid
}
}
return low
}

0 comments on commit d4d53fd

Please sign in to comment.