1/10
Loading...
🚤Lifeboat!
We need to rescue 4 people! Boat limit: 100kg Max 2 people per boat
Loading...
We need to rescue 4 people! Boat limit: 100kg Max 2 people per boat
You need to rescue people stranded on an island. Each lifeboat can carry at most 2 people with a weight limit. Find the minimum number of lifeboats needed to rescue everyone.
people = [70, 50, 80, 50], limit = 100
3
Sort: [50, 50, 70, 80] Boat1: 50+50=100 ✓ Boat2: 70 (alone) Boat3: 80 (alone) Total: 3 boats!