------
## 最终结论
```python
def num_rescue_boats(people, limit):
    people.sort()  # Sort the array of weights
    left, right = 0, len(people) - 1  # Initialize pointers
    boats_count = 0  # Initialize boat counter
    
    while left <= right:
        if people[left] + people[right] <= limit:  # If they can share a boat
            left += 1  # Move the lightest pointer
        right -= 1  # Always move the heaviest pointer
        boats_count += 1  # One boat is used
    
    return boats_count

# Example usage:
print(num_rescue_boats([3,2,2,1], 3))  # Output: 3
print(num_rescue_boats([1,2], 3))      # Output: 1
print(num_rescue_boats([3,5,3,4], 5))  # Output: 4
```