[Java, Python & C++] Easy to Understand and Efficient Solutions.
Approach\nTwo Pointer Approach\n\n\n# Complexity\n- Time complexity: O(nlogn)\n\n- Space complexity: O(n)\n\n\n# Code\n### Java\n\nclass Solution {\n    public 
# Approach\nTwo Pointer Approach\n\n\n# Complexity\n- Time complexity: O(nlogn)\n\n- Space complexity: O(n)\n\n\n# Code\n### Java\n```\nclass Solution {\n    public int numRescueBoats(int[] people, int limit) {\n        Arrays.sort(people);\n        int start = 0; \n        int end = people.length - 1;\n        int res = 0;\n\n        while (start <= end) {\n            if (people[start] + people[end] <= limit){\n                start++;\n            }\n            end--;\n            res++;\n        }\n\n        return res;\n    }\n}\n```\n\n### Python\n```\nclass Solution:\n    def numRescueBoats(self, people: List[int], limit: int) -> int:\n        people.sort()\n        start = 0\n        end = len(people) - 1\n        res = 0\n\n        while start <= end:\n            if people[start] + people[end] <= limit:\n                start += 1\n            end -= 1\n            res += 1\n\n        return res\n\n```\n\n### C++\n```\nclass Solution {\npublic:\n    int numRescueBoats(vector<int>& people, int limit) {\n        sort(people.begin(), people.end());\n        int start = 0; \n        int end = people.size() - 1;\n        int res = 0;\n\n        while (start <= end) {\n            if (people[start] + people[end] <= limit){\n                start++;\n            }\n            end--;\n            res++;\n        }\n\n        return res;\n    }\n};\n```
['Python', 'C++', 'Java', 'Python3']