leetcode

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

commit 84bc824a83e3940d657929bf99f37600793e6201
parent df6d89185b3c849cc4deacb024d749d1d05c4b69
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Wed,  8 Mar 2023 12:04:18 +0100

Daily Problem

Diffstat:
AProblems/0875.cpp | 15+++++++++++++++
MREADME.md | 1+
2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/Problems/0875.cpp b/Problems/0875.cpp @@ -0,0 +1,15 @@ +class Solution { +public: + int minEatingSpeed(vector<int> &piles, int h) { + int low = 1, high = INT_MAX, mid, count; + while (low < high) { + mid = low + (high - low) / 2, count = 0; + for (int pile : piles) count += ceil((double)pile / mid); + if (count <= h) + high = mid; + else + low = mid + 1; + } + return low; + } +}; diff --git a/README.md b/README.md @@ -473,4 +473,5 @@ for solving problems. | 2477 | Medium | [Minimum Fuel Cost to Report to the Capital](Problems/2477.cpp) | | 2492 | Medium | [Minimum Score of a Path Between Two Cities](Problems/2492.cpp) | | 2497 | Medium | [Maximum Star Sum of a Graph](Problems/2497.cpp) | +| 0875 | Medium | [Koko Eating Bananas](Problems/0875.cpp) |