diff --git "a/problems/0035.346円220円234円347円264円242円346円217円222円345円205円245円344円275円215円347円275円256円.md" "b/problems/0035.346円220円234円347円264円242円346円217円222円345円205円245円344円275円215円347円275円256円.md" index 5ed3ac5600..4b17bec679 100644 --- "a/problems/0035.346円220円234円347円264円242円346円217円222円345円205円245円344円275円215円347円275円256円.md" +++ "b/problems/0035.346円220円234円347円264円242円346円217円222円345円205円245円344円275円215円347円275円256円.md" @@ -270,6 +270,26 @@ func searchInsert(nums []int, target int) int { } ``` +### Rust + +```rust +impl Solution { + pub fn search_insert(nums: Vec, target: i32) -> i32 { + let mut left = 0; + let mut right = nums.len(); + while left < right { + let mid = (left + right) / 2; + match nums[mid].cmp(&target) { + Ordering::Less => left = mid + 1, + Ordering::Equal => return ((left + right) / 2) as i32, + Ordering::Greater => right = mid, + } + } + ((left + right) / 2) as i32 + } +} +``` + ### Python ```python class Solution: diff --git "a/problems/0704.344円272円214円345円210円206円346円237円245円346円211円276円.md" "b/problems/0704.344円272円214円345円210円206円346円237円245円346円211円276円.md" index 53f5331aac..51f48267f6 100644 --- "a/problems/0704.344円272円214円345円210円206円346円237円245円346円211円276円.md" +++ "b/problems/0704.344円272円214円345円210円206円346円237円245円346円211円276円.md" @@ -220,7 +220,8 @@ class Solution: (版本二)左闭右开区间 -```class Solution: +```python +class Solution: def search(self, nums: List[int], target: int) -> int: if nums is None or len(nums)==0: return -1

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