Daily Problem
Diffstat:
2 files changed, 19 insertions(+), 0 deletions(-)
@@ -0,0 +1,18 @@
class Solution {
public:
bool canPlaceFlowers(vector<int> &flowerbed, int n) {
int count = 1;
flowerbed.push_back(0);
flowerbed.push_back(1);
for (int crnt : flowerbed) {
if (!crnt)
count++;
else {
if (count >= 3) n -= (count - 3) / 2 + 1;
if (n <= 0) return true;
count = 0;
}
}
return false;
}
};
@@ -287,6 +287,7 @@
for solving problems.
| 0583 | Medium | [Delete Operation for Two Strings](Problems/0583.cpp) |
| 0589 | Easy | [N-ary Tree Preorder Traversal](Problems/0589.cpp) |
| 0590 | Easy | [N-ary Tree Postorder Traversal](Problems/0590.cpp) |
| 0605 | Easy | [Can Place Flowers](Problems/0605.cpp) |
| 0606 | Easy | [Construct String from Binary Tree ](Problems/0606.cpp) |
| 0617 | Easy | [Merge Two Binary Trees](Problems/0617.cpp) |
| 0621 | Medium | [Task Scheduler](Problems/0621.cpp) |