By Long Luo

# Greedy

We should let the Heaviest person match the lightest person and create the most pairs whose weight didn’t exceed the limit, and so on.

If not, let the heavy person occupy a whole boat.

I write the brute force code first.

It was ugly, then I wrote such code below.

## Analysis

• Time Complexity: $O(n \log n)$
• Space Complexity: $O(\log n)$

All suggestions are welcome.
If you have any query or suggestion please comment below.
Please upvote👍 if you like💗 it. Thank you:-)

Explore More Leetcode Solutions. 😉😃💗