for the input people = [1,2,3,4,5] and limit = 3, it would return 4, indicating that a minimum of 4 boats are needed to rescue all the people. The method sorts the people list in ascending order and uses two pointers to iterate through the list, assigning each pair of the lightest and heaviest people to a boat if their total weight is less than or equal to the limit. Hope this Helps :) Subscribe for more :)
@@techerror8 if we pair 1 and 5 and add them it would be 6 which is > 3 so we will send 5 alone in the boat but limit is 3 and 5 > 3 so how will it go in a boat, this keeps hunting me 🥲
Like 👍
Share 📣
Comment 💬
Click this link to Subscribe 👉tinyurl.com/4e2nj4vr
Press the Bell icon🔔for updates
Nice Explanation
Glad it Helped :)
good job, keep doing it
Glad it Helped :) Thank You :)
what if people = [1,2,3,4,5] and limit is only 3
for the input people = [1,2,3,4,5] and limit = 3, it would return 4, indicating that a minimum of 4 boats are needed to rescue all the people. The method sorts the people list in ascending order and uses two pointers to iterate through the list, assigning each pair of the lightest and heaviest people to a boat if their total weight is less than or equal to the limit. Hope this Helps :) Subscribe for more :)
@@techerror8 if we pair 1 and 5 and add them it would be 6 which is > 3 so we will send 5 alone in the boat but limit is 3 and 5 > 3 so how will it go in a boat, this keeps hunting me 🥲