File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 212
212
| 2309| [ 兼具大小写的最好英文字母] ( https://leetcode.cn/problems/greatest-english-letter-in-upper-and-lower-case/ ) | [ JavaScript] ( ./algorithms/greatest-english-letter-in-upper-and-lower-case.js ) | Easy|
213
213
| 2315| [ 统计星号] ( https://leetcode.cn/problems/count-asterisks/ ) | [ JavaScript] ( ./algorithms/count-asterisks.js ) | Easy|
214
214
| 2319| [ 判断矩阵是否是一个 X 矩阵] ( https://leetcode.cn/problems/check-if-matrix-is-x-matrix/ ) | [ JavaScript] ( ./algorithms/check-if-matrix-is-x-matrix.js ) | Easy|
215
+ | 2331| [ 计算布尔二叉树的值] ( https://leetcode.cn/problems/evaluate-boolean-binary-tree/ ) | [ JavaScript] ( ./algorithms/evaluate-boolean-binary-tree.js ) | Easy|
215
216
| 2351| [ 第一个出现两次的字母] ( https://leetcode.cn/problems/first-letter-to-appear-twice/ ) | [ JavaScript] ( ./algorithms/first-letter-to-appear-twice.js ) | Easy|
216
217
| 面试题 04.12| [ 面试题 04.12. 求和路径] ( https://leetcode.cn/problems/paths-with-sum-lcci/ ) | [ JavaScript] ( ./algorithms/paths-with-sum-lcci.js ) | Medium|
217
218
| 面试题 02.07| [ 面试题 02.07. 链表相交] ( https://leetcode.cn/problems/intersection-of-two-linked-lists-lcci/ ) | [ JavaScript] ( ./algorithms/intersection-of-two-linked-lists-lcci.js ) | Easy|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Definition for a binary tree node.
3
+ * function TreeNode(val, left, right) {
4
+ * this.val = (val===undefined ? 0 : val)
5
+ * this.left = (left===undefined ? null : left)
6
+ * this.right = (right===undefined ? null : right)
7
+ * }
8
+ */
9
+ /**
10
+ * 2331. 计算布尔二叉树的值
11
+ * @param {TreeNode } root
12
+ * @return {boolean }
13
+ */
14
+ var evaluateTree = function ( root ) {
15
+ if ( ! root ) return false ;
16
+ if ( root . val < 2 ) {
17
+ return ! ! root . val ;
18
+ }
19
+ const left = evaluateTree ( root . left ) ;
20
+ const right = evaluateTree ( root . right ) ;
21
+ if ( root . val === 2 ) {
22
+ return left || right ;
23
+ }
24
+ return left && right ;
25
+ } ;
You can’t perform that action at this time.
0 commit comments