File tree 3 files changed +49
-0
lines changed
solution/1800-1899/1887.Reduction Operations to Make the Array Elements Equal
3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -201,6 +201,24 @@ func reductionOperations(nums []int) int {
201
201
}
202
202
```
203
203
204
+ ### ** C#**
205
+
206
+ ``` cs
207
+ public class Solution {
208
+ public int ReductionOperations (int [] nums ) {
209
+ Array .Sort (nums );
210
+ int ans = 0 , up = 0 ;
211
+ for (int i = 1 ; i < nums .Length ; i ++ ) {
212
+ if (nums [i ] != nums [i - 1 ]) {
213
+ up ++ ;
214
+ }
215
+ ans += up ;
216
+ }
217
+ return ans ;
218
+ }
219
+ }
220
+ ```
221
+
204
222
### ** ...**
205
223
206
224
```
Original file line number Diff line number Diff line change @@ -183,6 +183,24 @@ func reductionOperations(nums []int) int {
183
183
}
184
184
```
185
185
186
+ ### ** C#**
187
+
188
+ ``` cs
189
+ public class Solution {
190
+ public int ReductionOperations (int [] nums ) {
191
+ Array .Sort (nums );
192
+ int ans = 0 , up = 0 ;
193
+ for (int i = 1 ; i < nums .Length ; i ++ ) {
194
+ if (nums [i ] != nums [i - 1 ]) {
195
+ up ++ ;
196
+ }
197
+ ans += up ;
198
+ }
199
+ return ans ;
200
+ }
201
+ }
202
+ ```
203
+
186
204
### ** ...**
187
205
188
206
```
Original file line number Diff line number Diff line change
1
+ public class Solution {
2
+ public int ReductionOperations ( int [ ] nums ) {
3
+ Array . Sort ( nums ) ;
4
+ int ans = 0 , up = 0 ;
5
+ for ( int i = 1 ; i < nums . Length ; i ++ ) {
6
+ if ( nums [ i ] != nums [ i - 1 ] ) {
7
+ up ++ ;
8
+ }
9
+ ans += up ;
10
+ }
11
+ return ans ;
12
+ }
13
+ }
You can’t perform that action at this time.
0 commit comments