🗓️ Daily LeetCoding Challenge Day 136|| 🔥 JAVA SOL
\n# Code\n\nclass Solution {\n    public int numRescueBoats(int[] people, int limit) {\n\n        int[] buckets = new int[limit + 1];\n        for(int weight : 
\n# Code\n```\nclass Solution {\n    public int numRescueBoats(int[] people, int limit) {\n\n        int[] buckets = new int[limit + 1];\n        for(int weight : people ){\n            buckets[weight]++;\n        } \n\n\n        int start = 0;\n        int end = buckets.length - 1;\n        int boats = 0;\n        while(start<=end){\n            while(start<=end && buckets[start] <= 0 ) start++;\n            while(start<=end && buckets[end] <= 0 ) end--;\n\n            if(buckets[start] <=0 && buckets[end] <=0) break;\n\n            boats++;\n            if(start + end <= limit){\n                buckets[start]--;\n            }\n            buckets[end]--;\n        }\n        return boats;\n    }\n}\n```
['Java']