Java || two pointer || O(n) || without sorting || faster than 100%
Please upvote if you like this solution~\n\nclass Solution {\n    public int numRescueBoats(int[] people, int limit) {\n        int max = 1;\n        int min = 
Please upvote if you like this solution~\n```\nclass Solution {\n    public int numRescueBoats(int[] people, int limit) {\n        int max = 1;\n        int min = limit;\n        // below O(n)\n        for (int i : people) {\n            max = Math.max(max, i);\n            min = Math.min(min, i);\n        }\n        // store people weight in map\n        // index is weight - min\n        // value is count\n        int[] map = new int[max - min + 1];\n        // O(n)\n        for (int i: people) {\n            map[i - min]++;\n        }\n        int count = 0;\n        int j = max - min; \n        int i = 0;\n        // Both people minus min, \n        // If add back, need add min * 2\n        min <<= 1;\n        // Two pointer, O(n)\n        while(true) {\n            while(i <= j && map[i] == 0) i++;\n            while(i <= j && map[j] == 0) j--;\n            if(i > j) break;\n            if((i != j || map[i] > 1) && (i + j + min) <= limit) {\n                map[i]--;\n                map[j]--;\n            } else {\n                map[j]--;\n            }\n            count++;\n        }\n        return count;\n    }\n}\n```
['Two Pointers', 'Java']