diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/boats_save_people.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/boats_save_people.cpp')
-rw-r--r-- | other/boats_save_people.cpp | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/other/boats_save_people.cpp b/other/boats_save_people.cpp deleted file mode 100644 index 7221191..0000000 --- a/other/boats_save_people.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// 881. Boats to Save People -#include "leetcode.h" - -/* - * given an array 'people' where 'people[i]' is the weight of the i'th person, - * and an infinite number of boats where each boat can carry a maximum weight of - * 'limit'. each boat carries at most two people at the same time, provided the - * sum of the weight of those people is at most 'limit'. return minimum number - * of boats to carry every person - */ - -class Solution { -public: - int numRescueBoats(vector<int> &people, int limit) { - sort(people.begin(), people.end()); - int max_weight = people.size() - 1, min_weight = 0, ans = 0; - while (min_weight <= max_weight) { - if (people[min_weight] + people[max_weight] <= limit) { - min_weight++; - max_weight--; - } else - max_weight--; - ans++; - } - return ans; - } -}; - -int main() { - Solution obj; - vector<int> p1 = {1, 2}, p2 = {3, 2, 2, 1}, p3 = {3, 5, 3, 4}; - printf("%d\n", obj.numRescueBoats(p1, 3)); // expect: 1 - printf("%d\n", obj.numRescueBoats(p2, 3)); // expect: 3 - printf("%d\n", obj.numRescueBoats(p3, 5)); // expect: 4 -} |