Daily Problem
Diffstat:
2 files changed, 33 insertions(+), 0 deletions(-)
@@ -0,0 +1,32 @@
class Solution {
public:
bool lemonadeChange(const vector<int> &bills) const {
int count[2] = {0, 0};
for (const int n : bills) {
switch (n) {
case 5: count[0]++; break;
case 10:
if (count[0] == 0) return false;
count[0]--;
count[1]++;
break;
case 20:
if (count[0] > 0 && count[1] > 0) {
count[0]--;
count[1]--;
break;
}
if (count[0] >= 3) {
count[0] -= 3;
break;
}
return false;
}
}
return true;
}
};
@@ -538,6 +538,7 @@
for solving problems.
| 0857 | Hard | [Minimum Cost to Hire K Workers](Problems/0857.cpp) |
| 0858 | Medium | [Mirror Reflection](Problems/0858.cpp) |
| 0859 | Easy | [Buddy Strings](Problems/0859.cpp) |
| 0860 | Easy | [Lemonade Change](Problems/0860.cpp) |
| 0861 | Medium | [Score After Flipping Matrix](Problems/0861.cpp) |
| 0863 | Medium | [All Nodes Distance K in Binary Tree](Problems/0863.cpp) |
| 0864 | Hard | [Shortest Path to Get All Keys](Problems/0864.cpp) |