Java | 2 pointers O(N log N) | 90% Faster
The trick in this question is that the boat fits 2 even if more can fit the limit\nso [2,2,2,2] and limit 8 the boats count required is 2  because the max peopl
The trick in this question is that the boat fits 2 even if more can fit the limit\nso `[2,2,2,2]` and limit `8` the boats count required is `2`  because the max people you can get on a single boat is `2`\n\n```\nclass Solution {\n    public int numRescueBoats(int[] p, int k) {\n        // Sort the array\n        Arrays.sort(p);\n        // Lightest person is always on the LEFT\n        // Heaviest person is always on the RIGHT\n        \n        int ans = 0;\n\n        int left = 0;\n        int right = p.length-1;\n        \n        while(left <= right) {\n            // right person is too heavy lets put him in a single boat\n            if(p[left] + p[right] > k) {\n                right--;\n            } else {\n                // left and right will fit in the boat :+1\n                left++;\n                right--;\n            }\n            \n            ans++;\n        }\n        \n        return ans;\n    }\n}\n```
[]