leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE | |
commit | fdeaff3161d68609e4b8c3fac504b84a4a05e213 |
parent | 13a3cc7d8a210c47912a3ad5a48a2c4446d17900 |
author | Dimitrije Dobrota <mail@dimitrijedobrota.com> |
date | Tue, 7 Nov 2023 18:38:20 +0000 |
Daily Problem
Diffstat:A | Problems/1921.cpp | | | +++++++++++++++ |
M | README.md | | | + |
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/Problems/1921.cpp b/Problems/1921.cpp
@@ -0,0 +1,15 @@
class Solution {
public:
int eliminateMaximum(const vector<int> &dist, const vector<int> &speed) const {
static float time[100001];
const int n = dist.size();
for (int i = 0; i < n; i++)
time[i] = (float)dist[i] / (float)speed[i];
sort(begin(time), begin(time) + n);
for (int i = 0; i < n; i++)
if (time[i] <= i) return i;
return n;
}
};
diff --git a/README.md b/README.md
@@ -749,6 +749,7 @@ for solving problems.
| 1899 | Medium | [Merge Triplets to Form Target Triplet](Problems/1899.cpp) |
| 1905 | Medium | [Count Sub Islands](Problems/1905.cpp) |
| 1910 | Medium | [Remove All Occurrences of a Substring](Problems/1910.cpp) |
| 1921 | Medium | [Eliminate Maximum Number of Monsters](Problems/1921.cpp) |
| 1926 | Medium | [Nearest Exit from Entrance in Maze](Problems/1926.cpp) |
| 1947 | Medium | [Maximum Compatibility Score Sum](Problems/1947.cpp) |
| 1962 | Medium | [Remove Stones to Minimize the Total](Problems/1962.cpp) |