File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Leetcode/0875.Koko-Eating-Bananas Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 6363## 題目
6464
6565## 題目大意
66-
66+ 珂珂喜歡吃香蕉。 這裡有 N 堆香蕉,第 i 堆中有 piles[ i] 根香蕉。 警衛已經離開了,將在 H 小時後回來。
67+ 可以決定她吃香蕉的速度 K (單位:根/小時)。 每個小時,她將會選擇一堆香蕉,從中吃掉 K 根。 如果這堆香蕉少於 K 根,她將吃掉這堆的所有香蕉,然後這一小時內不會再吃更多的香蕉。
68+ 珂珂喜歡慢慢吃,但仍然想在警衛回來前吃掉所有的香蕉。
69+ 返回她可以在 H 小時內吃掉所有香蕉的最小速度 K(K 為整數)。
6770
6871## 解題思路
72+ 這一題可以用二分搜索來解答。 在 [ 0 , max(piles)] 的範圍內搜索,二分的過程都是常規思路。 判斷是否左右邊界如果劃分的時候需要注意題目中給的限定條件。 當香蕉個數小於 k 的時候,那個小時不能再吃其他香蕉了。
6973
7074## Big O
7175
7579## 來源
7680* https://leetcode.com/problems/koko-eating-bananas/description/
7781* https://leetcode.cn/problems/koko-eating-bananas/description/
82+ * https://books.halfrost.com/leetcode/ChapterFour/0800~0899/0875.Koko-Eating-Bananas/
7883
7984## 解答
8085https://github.com/kimi0230/LeetcodeGolang/blob/master/Leetcode/0875.Koko-Eating-Bananas/main.go
You can’t perform that action at this time.
0 commit comments