File tree 3 files changed +40
-0
lines changed
solution/1800-1899/1877.Minimize Maximum Pair Sum in Array
3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,21 @@ function minPairSum(nums: number[]): number {
136
136
}
137
137
```
138
138
139
+ ### ** C#**
140
+
141
+ ``` cs
142
+ public class Solution {
143
+ public int MinPairSum (int [] nums ) {
144
+ Array .Sort (nums );
145
+ int ans = 0 , n = nums .Length ;
146
+ for (int i = 0 ; i < n >> 1 ; ++ i ) {
147
+ ans = Math .Max (ans , nums [i ] + nums [n - i - 1 ]);
148
+ }
149
+ return ans ;
150
+ }
151
+ }
152
+ ```
153
+
139
154
### ** ...**
140
155
141
156
```
Original file line number Diff line number Diff line change @@ -122,6 +122,21 @@ function minPairSum(nums: number[]): number {
122
122
}
123
123
```
124
124
125
+ ### ** C#**
126
+
127
+ ``` cs
128
+ public class Solution {
129
+ public int MinPairSum (int [] nums ) {
130
+ Array .Sort (nums );
131
+ int ans = 0 , n = nums .Length ;
132
+ for (int i = 0 ; i < n >> 1 ; ++ i ) {
133
+ ans = Math .Max (ans , nums [i ] + nums [n - i - 1 ]);
134
+ }
135
+ return ans ;
136
+ }
137
+ }
138
+ ```
139
+
125
140
### ** ...**
126
141
127
142
```
Original file line number Diff line number Diff line change
1
+ public class Solution {
2
+ public int MinPairSum ( int [ ] nums ) {
3
+ Array . Sort ( nums ) ;
4
+ int ans = 0 , n = nums . Length ;
5
+ for ( int i = 0 ; i < n > > 1 ; ++ i ) {
6
+ ans = Math . Max ( ans , nums [ i ] + nums [ n - i - 1 ] ) ;
7
+ }
8
+ return ans ;
9
+ }
10
+ }
You can’t perform that action at this time.
0 commit comments