Java 0(nlogn) two pointer.
```\nclass Solution {\n    public int numRescueBoats(int[] people, int limit) {\n        Arrays.sort(people);\n        int left = 0,right=people.length-1;\n    
```\nclass Solution {\n    public int numRescueBoats(int[] people, int limit) {\n        Arrays.sort(people);\n        int left = 0,right=people.length-1;\n        int boats = 0;\n        while(left <= right){\n            int sum = people[left] + people[right];\n            if(sum <= limit){\n                left++;\n                right--;\n           }else\n                right--;\n            \n\t\t\tboats++;\n        }\n      \n        return boats;\n    }\n}
['Two Pointers', 'Java']