Skip to content

Commit 547c83c

Browse files
committed
docs: add koko eating bananas problem description
1 parent 7d0b6a9 commit 547c83c

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/medium/readme.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,3 +693,39 @@ Put the code below in main.rs and run `cargo run`
693693
let result = medium::car_fleet::car_fleet(target, position, speed);
694694
println!("result: {}", result);
695695
```
696+
697+
# 875. Koko Eating Bananas
698+
699+
## Description
700+
701+
Koko loves to eat bananas. There are n piles of bananas, the ith pile has piles[i] bananas. The guards have gone and will come back in h hours.
702+
703+
Koko can decide her bananas-per-hour eating speed of k. Each hour, she chooses some pile of bananas and eats k bananas from that pile. If the pile has less than k bananas, she eats all of them instead and will not eat any more bananas during this hour.
704+
705+
Koko likes to eat slowly but still wants to finish eating all the bananas before the guards return.
706+
707+
Return the minimum integer k such that she can eat all the bananas within h hours.
708+
709+
## Examples
710+
711+
```text
712+
Input: piles = [3,6,7,11], h = 8
713+
Output: 4
714+
715+
Input: piles = [30,11,23,4,20], h = 5
716+
Output: 30
717+
718+
Input: piles = [30,11,23,4,20], h = 6
719+
Output: 23
720+
```
721+
722+
## How to Run in main.rs
723+
724+
Put the code below in main.rs and run `cargo run`
725+
726+
```rust
727+
let piles = vec![3, 6, 7, 11];
728+
let h = 8;
729+
let result = medium::min_eating_speed::min_eating_speed(piles, h);
730+
println!("result: {}", result);
731+
```

0 commit comments

Comments
 (0)