Skip to content

Commit

Permalink
Merge pull request neetcode-gh#1814 from AP-Repositories/patch-64
Browse files Browse the repository at this point in the history
Create 0035-search-insert-position.go
  • Loading branch information
Ahmad-A0 authored Jan 1, 2023
2 parents 5224479 + d4d53fd commit 9035911
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 9035911

Please sign in to comment.