File tree 2 files changed +35
-0
lines changed
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,26 @@ public:
125
125
};
126
126
```
127
127
128
+ ### **Rust**
129
+
130
+ ```rust
131
+ impl Solution {
132
+ pub fn min_array(numbers: Vec<i32>) -> i32 {
133
+ let mut l = 0;
134
+ let mut r = numbers.len() - 1;
135
+ while l < r {
136
+ let mid = l + r >> 1;
137
+ match numbers[mid].cmp(&numbers[r]) {
138
+ std::cmp::Ordering::Less => r = mid,
139
+ std::cmp::Ordering::Equal => r -= 1,
140
+ std::cmp::Ordering::Greater => l = mid + 1,
141
+ }
142
+ }
143
+ numbers[l]
144
+ }
145
+ }
146
+ ```
147
+
128
148
### ** ...**
129
149
130
150
```
Original file line number Diff line number Diff line change
1
+ impl Solution {
2
+ pub fn min_array ( numbers : Vec < i32 > ) -> i32 {
3
+ let mut l = 0 ;
4
+ let mut r = numbers. len ( ) - 1 ;
5
+ while l < r {
6
+ let mid = l + r >> 1 ;
7
+ match numbers[ mid] . cmp ( & numbers[ r] ) {
8
+ std:: cmp:: Ordering :: Less => r = mid,
9
+ std:: cmp:: Ordering :: Equal => r -= 1 ,
10
+ std:: cmp:: Ordering :: Greater => l = mid + 1 ,
11
+ }
12
+ }
13
+ numbers[ l]
14
+ }
15
+ }
You can’t perform that action at this time.
0 commit comments