1 Random Problem
Diffstat:
2 files changed, 26 insertions(+), 0 deletions(-)
@@ -0,0 +1,25 @@
class Solution {
public:
bool isPossible(const vector<int> &nums) const {
unordered_map<int, int> left, end;
for (const int n : nums)
left[n]++;
for (const int n : nums) {
if (!left[n]) continue;
left[n]--;
if (end[n - 1] > 0) {
end[n - 1]--;
end[n]++;
} else if (left[n + 1] > 0 && left[n + 2] > 0) {
left[n + 1]--;
left[n + 2]--;
end[n + 2]++;
} else
return false;
}
return true;
}
};
@@ -443,6 +443,7 @@
for solving problems.
| 0653 | Easy | [Two Sum IV - Input is a BST](Problems/0653.cpp) |
| 0654 | Medium | [Maximum Binary Tree](Problems/0654.cpp) |
| 0655 | Medium | [Print Binary Tree](Problems/0655.cpp) |
| 0659 | Medium | [Split Array into Consecutive Subsequences](Problems/0659.cpp) |
| 0661 | Easy | [Image Smoother](Problems/0661.cpp) |
| 0662 | Medium | [Maximum Width of Binary Tree](Problems/0662.cpp) |
| 0664 | Hard | [Strange Printer](Problems/0664.cpp) |