[Java] 100 % faster O(N) Solution - easy to understand code
\n\nclass Solution {\n    public int numRescueBoats(int[] people, int limit) {\n        int[] map = new int[limit + 1];\n        \n        for(int x : people){\
![image](https://assets.leetcode.com/users/images/be8c24b6-7a69-4459-9b58-ce043b98ad2c_1595822310.6821368.png)\n```\nclass Solution {\n    public int numRescueBoats(int[] people, int limit) {\n        int[] map = new int[limit + 1];\n        \n        for(int x : people){\n            map[x]++;\n        }\n        \n        int i = 0;\n        int j = limit;\n        int numPeople = 0;\n        \n        while(i <= j){\n            while(map[i] == 0 && i <= j){\n                i++;\n            }\n            while(map[j] == 0 && i <= j){\n                j--;\n            }\n            if(i + j <= limit){\n                if(map[j] > 0)\n                   map[j]--;\n                if(map[i] > 0)\n                   map[i]--;\n            }\n            else{\n                if(map[j] > 0)\n                   map[j]--;\n            }\n            numPeople++;\n        }\n        return numPeople - 1;\n    }\n}\n```
['Java']