Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1f69e60

Browse files
Add Solution.go for 0035.Search Insert Position
1 parent eb0435d commit 1f69e60

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
func searchInsert(nums []int, target int) int {
2+
left, right := 0, len(nums)
3+
for left < right {
4+
mid := (left + right) >> 1
5+
if nums[mid] >= target {
6+
right = mid
7+
} else {
8+
left = mid + 1
9+
}
10+
}
11+
return left
12+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /