leetcode

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

commit1211fafde7ffa16436079624c71668c7517a5525
parentac6c249437469f785c2af42c18cf99309cf82b3a
authorDimitrije Dobrota <mail@dimitrijedobrota.com>
dateMon, 3 Apr 2023 11:01:24 +0200

Daily Problem

Diffstat:
AProblems/0881.cpp|++++++++++++++
MREADME.md|+

2 files changed, 15 insertions(+), 0 deletions(-)


diff --git a/Problems/0881.cpp b/Problems/0881.cpp

@@ -0,0 +1,14 @@

class Solution {
public:
int numRescueBoats(vector<int> &people, int limit) {
sort(people.begin(), people.end());
int low = 0, high = people.size() - 1, res = 0;
while (low <= high) {
if (people[low] + people[high] <= limit) low++;
high--;
res++;
}
return res;
}
};

diff --git a/README.md b/README.md

@@ -342,6 +342,7 @@ for solving problems.

| 0872 | Easy | [Leaf-Similar Trees](Problems/0872.cpp) |
| 0875 | Medium | [Koko Eating Bananas](Problems/0875.cpp) |
| 0876 | Easy | [Middle of the Linked List](Problems/0876.cpp) |
| 0881 | Medium | [Boats to Save People](Problems/0881.cpp) |
| 0884 | Easy | [Uncommon Words from Two Sentences](Problems/0884.cpp) |
| 0886 | Medium | [Possible Bipartition](Problems/0886.cpp) |
| 0897 | Easy | [Increasing Order Search Tree](Problems/0897.cpp) |