【LeetCode】2331. 计算布尔二叉树的值
class Solution {
public:
bool evaluateTree(TreeNode* root) {
return dfs(root);
}
bool dfs(TreeNode * root){
switch(root->val){
case(0) : return false;
case(1) : return true;
case(2) : return dfs(root->left) || dfs(root->right);
case(3) : return dfs(root->left) && dfs(root->right);
}
return false;
}
};