leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE |

commitdf6d89185b3c849cc4deacb024d749d1d05c4b69
parent250b2a522bb491ec6934fef0180978bb9e9bafb1
authorDimitrije Dobrota <mail@dimitrijedobrota.com>
dateTue, 7 Mar 2023 20:12:57 +0100

Daily Problem

Diffstat:
AProblems/2187.cpp|+++++++++++++++
MREADME.md|+

2 files changed, 16 insertions(+), 0 deletions(-)


diff --git a/Problems/2187.cpp b/Problems/2187.cpp

@@ -0,0 +1,15 @@

class Solution {
public:
long long minimumTime(vector<int> &time, int totalTrips) {
long long low = 1, high = 1e14, mid, count;
while (low < high) {
mid = low + (high - low) / 2, count = 0;
for (long long t : time) count += mid / t;
if (count >= totalTrips)
high = mid;
else
low = mid + 1;
}
return low;
}
};

diff --git a/README.md b/README.md

@@ -445,6 +445,7 @@ for solving problems.

| 2131 | Medium | [Longest Palindrome by Concatenating Two Letter Words](Problems/2131.cpp) |
| 2177 | Medium | [Find Three Consecutive Integers That Sum to a Given Number](Problems/2177.cpp) |
| 2181 | Medium | [Merge Nodes in Between Zeros](Problems/2181.cpp) |
| 2187 | Medium | [Minimum Time to Complete Trips](Problems/2187.cpp) |
| 2192 | Medium | [All Ancestors of a Node in a Directed Acyclic Graph](Problems/2192.cpp) |
| 2235 | Easy | [Add Two Integers](Problems/2235.cpp) |
| 2236 | Easy | [Root Equals Sum of Children](Problems/2236.cpp) |