File tree 3 files changed +79
-0
lines changed
solution/2700-2799/2733.Neither Minimum nor Maximum
3 files changed +79
-0
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,34 @@ func findNonMinOrMax(nums []int) int {
131
131
}
132
132
```
133
133
134
+ ### ** Rust**
135
+
136
+ ``` rust
137
+ impl Solution {
138
+ pub fn find_non_min_or_max (nums : Vec <i32 >) -> i32 {
139
+ let mut mi = 100 ;
140
+ let mut mx = 0 ;
141
+
142
+ for & ele in nums . iter () {
143
+ if ele < mi {
144
+ mi = ele ;
145
+ }
146
+ if ele > mx {
147
+ mx = ele ;
148
+ }
149
+ }
150
+
151
+ for & ele in nums . iter () {
152
+ if ele != mi && ele != mx {
153
+ return ele ;
154
+ }
155
+ }
156
+
157
+ - 1
158
+ }
159
+ }
160
+ ```
161
+
134
162
### ** ...**
135
163
136
164
```
Original file line number Diff line number Diff line change @@ -124,6 +124,34 @@ func findNonMinOrMax(nums []int) int {
124
124
}
125
125
```
126
126
127
+ ### ** Rust**
128
+
129
+ ``` rust
130
+ impl Solution {
131
+ pub fn find_non_min_or_max (nums : Vec <i32 >) -> i32 {
132
+ let mut mi = 100 ;
133
+ let mut mx = 0 ;
134
+
135
+ for & ele in nums . iter () {
136
+ if ele < mi {
137
+ mi = ele ;
138
+ }
139
+ if ele > mx {
140
+ mx = ele ;
141
+ }
142
+ }
143
+
144
+ for & ele in nums . iter () {
145
+ if ele != mi && ele != mx {
146
+ return ele ;
147
+ }
148
+ }
149
+
150
+ - 1
151
+ }
152
+ }
153
+ ```
154
+
127
155
### ** ...**
128
156
129
157
```
Original file line number Diff line number Diff line change
1
+ impl Solution {
2
+ pub fn find_non_min_or_max ( nums : Vec < i32 > ) -> i32 {
3
+ let mut mi = 100 ;
4
+ let mut mx = 0 ;
5
+
6
+ for & ele in nums. iter ( ) {
7
+ if ele < mi {
8
+ mi = ele;
9
+ }
10
+ if ele > mx {
11
+ mx = ele;
12
+ }
13
+ }
14
+
15
+ for & ele in nums. iter ( ) {
16
+ if ele != mi && ele != mx {
17
+ return ele;
18
+ }
19
+ }
20
+
21
+ -1
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments