diff --git a/problems/0035.搜索插入位置.md b/problems/0035.搜索插入位置.md index 04dd0cac..80b7e40e 100644 --- a/problems/0035.搜索插入位置.md +++ b/problems/0035.搜索插入位置.md @@ -258,6 +258,37 @@ public int searchInsert(int[] nums, int target) { +### C# + +```go +public int SearchInsert(int[] nums, int target) { + + var left = 0; + var right = nums.Length - 1; + + while (left <= right) { + + var curr = (left + right) / 2; + + if (nums[curr] == target) + { + return curr; + } + + if (target > nums[curr]) { + left = curr + 1; + } + else { + right = curr - 1; + } + } + + return left; +} +``` + + + ### Golang ```go @@ -500,3 +531,4 @@ int searchInsert(int* nums, int numsSize, int target){ +