Title: #2331 - Evaluate Boolean Binary Tree - LeetCode JavaScript Solutions
Open Graph Title: #2331 - Evaluate Boolean Binary Tree - LeetCode JavaScript Solutions
X Title: #2331 - Evaluate Boolean Binary Tree - LeetCode JavaScript Solutions
Description: You are given the root of a full binary tree with the following properties: Leaf nodes have either the value 0 or 1, where 0 represents Fal...
Open Graph Description: You are given the root of a full binary tree with the following properties: Leaf nodes have either the value 0 or 1, where 0 represents Fal...
X Description: You are given the root of a full binary tree with the following properties: Leaf nodes have either the value 0 or 1, where 0 represents Fal...
Keywords:
Opengraph URL: https://leetcodejavascript.com/solutions/evaluate-boolean-binary-tree
Domain: leetcodejavascript.com
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/evaluate-boolean-binary-tree","name":"#2331 - Evaluate Boolean Binary Tree - LeetCode JavaScript Solutions","description":"You are given the root of a full binary tree with the following properties: Leaf nodes have either the value 0 or 1, where 0 represents Fal...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * Definition for a binary tree node.\n * function TreeNode(val, left, right) {\n * this.val = (val===undefined ? 0 : val)\n * this.left = (left===undefined ? null : left)\n * this.right = (right===undefined ? null : right)\n * }\n */\n/**\n * @param {TreeNode} root\n * @return {boolean}\n */\nvar evaluateTree = function(root) {\n if (!root.left && !root.right) return root.val === 1;\n\n const leftResult = evaluateTree(root.left);\n const rightResult = evaluateTree(root.right);\n\n return root.val === 2 ? leftResult || rightResult : leftResult && rightResult;\n};","keywords":"LeetCode 2331, #2331 - Evaluate Boolean Binary Tree, Easy, JavaScript solution","learningResourceType":"Code","isAccessibleForFree":true,"educationalLevel":"intermediate","interactivityType":"mixed"}
| author | LeetCodeJavascript.com |
| og:type | article |
| og:image | https://leetcodejavascript.com/og-image.jpg |
| og:site_name | LeetCode JavaScript Solutions |
| twitter:card | summary_large_image |
| twitter:url | https://leetcodejavascript.com/solutions/evaluate-boolean-binary-tree |
| twitter:image | https://leetcodejavascript.com/og-image.jpg |
| twitter:creator | @joshcrozier |
| theme-color | #1f2937 |
Links:
| LeetCodeJavascript.com | https://leetcodejavascript.com/ |
| Star on GitHub | https://github.com/JoshCrozier/leetcode-javascript |
| Back to all solutions | https://leetcodejavascript.com |
| View on LeetCode | https://leetcode.com/problems/evaluate-boolean-binary-tree/ |
| View on GitHub | https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/2331-evaluate-boolean-binary-tree.js |
| Depth-First Search | https://leetcodejavascript.com/tags/depth-first-search |
| Tree | https://leetcodejavascript.com/tags/tree |
| Binary Tree | https://leetcodejavascript.com/tags/binary-tree |
| Josh Crozier | https://joshcrozier.com |
Viewport: width=device-width,initial-scale=1
Robots: index, follow