23311 [LeetCode] 2331. Evaluate Boolean Binary Tree, cpp Solution use recursive structure Tag Full binary tree class Solution { public: bool evaluateTree(TreeNode* root) { bool retval = true; if (root->left != nullptr && root->left != nullptr) // full binary tree { if (root->val == 2) // OR { retval = evaluateTree(root->left) || evaluateTree(root->right);; } else // operta = 3, AND { retval = evaluateTree(root->left) && evaluateTree(root->right);; } }.. 2023. 1. 10. 이전 1 다음