Skip to content

Commit

Permalink
Create 1921_Eliminate_Maximum_Number_of_Monsters.java
Browse files Browse the repository at this point in the history
  • Loading branch information
mkhuzaima committed Nov 7, 2023
1 parent 9a69be2 commit f1193bc
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions 1921_Eliminate_Maximum_Number_of_Monsters.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// id: 1921
// Name: Eliminate Maximum Number of Monsters
// link: https://leetcode.com/problems/eliminate-maximum-number-of-monsters/
// Difficulty: Medium

class Solution {
public int eliminateMaximum(int[] dist, int[] speed) {
int n = dist.length;
double [] time = new double[n];

for (int i = 0; i < n; i++) {
time[i] = dist[i]*1.0 / speed[i];
}

Arrays.sort(time);

int i = 0;
while (i < n && time[i] > i) {
i++;
}
return i;
}
}

0 comments on commit f1193bc

Please sign in to comment.