Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

881. Boats to Save People #53

Open
F4NT0 opened this issue May 4, 2024 · 0 comments
Open

881. Boats to Save People #53

F4NT0 opened this issue May 4, 2024 · 0 comments
Assignees
Labels
Medium Medium Questions Ready to code Description from the Question was updated with code and text
Milestone

Comments

@F4NT0
Copy link
Owner

F4NT0 commented May 4, 2024

You are given an array people where people[i] is the weight of the i^th person, and an infinite number of boats where each boat can carry a maximum weight of limit. Each boat carries at most two people at the same time, provided the sum of the weight of those people is at most limit.

Return the minimum number of boats to carry every given person.

##Example 1:

  • Input: people = [1,2], limit = 3
  • Output: 1
  • Explanation: 1 boat (1, 2)

Example 2:

  • Input: people = [3,2,2,1], limit = 3
  • Output: 3
  • Explanation: 3 boats (1, 2), (2) and (3)

Example 3:

  • Input: people = [3,5,3,4], limit = 5
  • Output: 4
  • Explanation: 4 boats (3), (3), (4), (5)

Constraints:

  • 1 <= people.length <= 5 * 104
  • 1 <= people[i] <= limit <= 3 * 104
@F4NT0 F4NT0 added Medium Medium Questions Ready to code Description from the Question was updated with code and text labels May 4, 2024
@F4NT0 F4NT0 added this to the May LeetCode milestone May 4, 2024
@F4NT0 F4NT0 self-assigned this May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Medium Medium Questions Ready to code Description from the Question was updated with code and text
Projects
None yet
Development

No branches or pull requests

1 participant