diff --git a/C++/Tress/2331.Evaluate Boolean Binary Tree.cpp b/C++/Tress/2331.Evaluate Boolean Binary Tree.cpp new file mode 100644 index 00000000..0c2c6543 --- /dev/null +++ b/C++/Tress/2331.Evaluate Boolean Binary Tree.cpp @@ -0,0 +1,11 @@ + +class Solution { +public: + bool evaluateTree(TreeNode* root) { + if( root->val ==1)return true; + if( root->val ==0)return false; + if (root->val ==2)return evaluateTree(root->left) or evaluateTree(root->right); + if(root->val ==3)return evaluateTree(root->left) and evaluateTree (root->right); + return true; + } +};