[C++/Java/Python] Two Pointers
Sort people.\nFor the current heaviest person, we try to let him go with the lightest person.\nAs all people need to get on the boat. \nIf the sum of weight is 
Sort people.\nFor the current heaviest person, we try to let him go with the lightest person.\nAs all people need to get on the boat. \nIf the sum of weight is over the limit, we have to let the heaviest go alone.\nNo one can take the same boat with him.\n\nAt the end of for loop, it may happend that `i = j`.\nBut it won\'t change the result so don\'t worry about it.\n\n**Time Complexity**:\nO(NlogN)\n\n**C++:**\n```\n    int numRescueBoats(vector<int> people, int limit) {\n        int i, j;\n        sort(people.rbegin(), people.rend());\n        for (i = 0, j = people.size() - 1; i <= j; ++i)\n            if (people[i] + people[j] <= limit) j--;\n        return i;\n    }\n```\n\n**Java:**\n```\n    public int numRescueBoats(int[] people, int limit) {\n        Arrays.sort(people);\n        int i, j;\n        for (i = 0, j = people.length - 1; i <= j; --j)\n            if (people[i] + people[j] <= limit) ++i;\n        return people.length - 1 - j;\n    }\n```\n**Python:**\n```\n    def numRescueBoats(self, people, limit):\n        people.sort(reverse=True)\n        i, j = 0, len(people) - 1\n        while i <= j:\n            if people[i] + people[j] <= limit: j -= 1\n            i += 1\n        return i\n```
[]