题目:
题目解析:
算法解析:
代码:
public boolean evaluateTree(TreeNode root) {if(root.left == null && root.right == null) return root.val == 1 ? true : false;boolean leftTree = evaluateTree(root.left);boolean rightTree = evaluateTree(root.right);return root.val == 2 ? leftTree | rightTree : leftTree & rightTree;}