Leetcode #881: Boats to Save People
Link to today's POTD (Leetcode).
https://leetcode.com/problems/boats-to-save-people/
You are given an array people where people[i] is the weight of the i<sup>th</sup> person, and an infinite number of boats where each boat can carry a maximum weig...
vaishalionlc.hashnode.dev4 min read
Gian Giacomo Patteri
Hi,
I tried your solution with this input: people = { 80, 60, 60, 50, 40, 20, 20, 20 } limit = 80
The result was 4 but it should be 5.
I would change your while (x < y) to while (x <= y).
I'm just starting to play with leetcode and Maybe I misunderstood something.
Thanks J