1 Random Problem
Diffstat:
2 files changed, 15 insertions(+), 0 deletions(-)
@@ -0,0 +1,14 @@
class Solution {
public:
int rob(TreeNode *root) const {
if (!root) return 0;
if (root->val < 0) return -root->val;
int res = root->val;
if (root->left) res += rob(root->left->left) + rob(root->left->right);
if (root->right) res += rob(root->right->left) + rob(root->right->right);
root->val = -max(res, rob(root->left) + rob(root->right));
return -root->val;
}
};
@@ -276,6 +276,7 @@
for solving problems.
| 0328 | Medium | [Odd Even Linked List](Problems/0328.cpp) |
| 0332 | Hard | [Reconstruct Itinerary](Problems/0332.cpp) |
| 0334 | Medium | [Increasing Triplet Subsequence](Problems/0334.cpp) |
| 0337 | Medium | [House Robber III](Problems/0337.cpp) |
| 0338 | Easy | [Counting Bits](Problems/0338.cpp) |
| 0341 | Medium | [Flatten Nested List Iterator](Problems/0341.cpp) |
| 0342 | Easy | [Power of Four](Problems/0342.cpp) |