leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0881.cpp (353B)


0 class Solution { 1 public: 2 int numRescueBoats(vector<int> &people, int limit) { 3 sort(people.begin(), people.end()); 4 int low = 0, high = people.size() - 1, res = 0; 5 while (low <= high) { 6 if (people[low] + people[high] <= limit) low++; 7 high--; 8 res++; 9 } 10 11 return res; 12 } 13 };