File tree 3 files changed +58
-0
lines changed
solution/1900-1999/1921.Eliminate Maximum Number of Monsters
3 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -202,6 +202,27 @@ var eliminateMaximum = function (dist, speed) {
202
202
};
203
203
```
204
204
205
+ ### ** C#**
206
+
207
+ ``` cs
208
+ public class Solution {
209
+ public int EliminateMaximum (int [] dist , int [] speed ) {
210
+ int n = dist .Length ;
211
+ int [] times = new int [n ];
212
+ for (int i = 0 ; i < n ; ++ i ) {
213
+ times [i ] = (dist [i ] - 1 ) / speed [i ];
214
+ }
215
+ Array .Sort (times );
216
+ for (int i = 0 ; i < n ; ++ i ) {
217
+ if (times [i ] < i ) {
218
+ return i ;
219
+ }
220
+ }
221
+ return n ;
222
+ }
223
+ }
224
+ ```
225
+
205
226
### ** ...**
206
227
207
228
```
Original file line number Diff line number Diff line change @@ -177,6 +177,27 @@ var eliminateMaximum = function (dist, speed) {
177
177
};
178
178
```
179
179
180
+ ### ** C#**
181
+
182
+ ``` cs
183
+ public class Solution {
184
+ public int EliminateMaximum (int [] dist , int [] speed ) {
185
+ int n = dist .Length ;
186
+ int [] times = new int [n ];
187
+ for (int i = 0 ; i < n ; ++ i ) {
188
+ times [i ] = (dist [i ] - 1 ) / speed [i ];
189
+ }
190
+ Array .Sort (times );
191
+ for (int i = 0 ; i < n ; ++ i ) {
192
+ if (times [i ] < i ) {
193
+ return i ;
194
+ }
195
+ }
196
+ return n ;
197
+ }
198
+ }
199
+ ```
200
+
180
201
### ** ...**
181
202
182
203
```
Original file line number Diff line number Diff line change
1
+ public class Solution {
2
+ public int EliminateMaximum ( int [ ] dist , int [ ] speed ) {
3
+ int n = dist . Length ;
4
+ int [ ] times = new int [ n ] ;
5
+ for ( int i = 0 ; i < n ; ++ i ) {
6
+ times [ i ] = ( dist [ i ] - 1 ) / speed [ i ] ;
7
+ }
8
+ Array . Sort ( times ) ;
9
+ for ( int i = 0 ; i < n ; ++ i ) {
10
+ if ( times [ i ] < i ) {
11
+ return i ;
12
+ }
13
+ }
14
+ return n ;
15
+ }
16
+ }
You can’t perform that action at this time.
0 commit comments