Skip to content

Commit e5558e5

Browse files
authored
feat: add cs solution to lc problem: No.1921 (#1939)
1 parent c374589 commit e5558e5

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

solution/1900-1999/1921.Eliminate Maximum Number of Monsters/README.md

+21
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,27 @@ var eliminateMaximum = function (dist, speed) {
202202
};
203203
```
204204

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+
205226
### **...**
206227

207228
```

solution/1900-1999/1921.Eliminate Maximum Number of Monsters/README_EN.md

+21
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,27 @@ var eliminateMaximum = function (dist, speed) {
177177
};
178178
```
179179

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+
180201
### **...**
181202

182203
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
}

0 commit comments

Comments
 (0)