Skip to content

Commit 0cbe23b

Browse files
committed
Runtime: 166 ms (Top 48.15%) | Memory: 52.1 MB (Top 16.67%)
1 parent 326ebdd commit 0cbe23b

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,37 @@
1+
// Runtime: 166 ms (Top 48.15%) | Memory: 52.1 MB (Top 16.67%)
12
/**
23
* Definition for a binary tree node.
34
* 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)
5+
* this.val = (val===undefined ? 0 : val)
6+
* this.left = (left===undefined ? null : left)
7+
* this.right = (right===undefined ? null : right)
78
* }
89
*/
910
/**
1011
* @param {TreeNode} root
1112
*/
1213
var FindElements = function(root) {
1314
this.st = new Set()
14-
15+
1516
recover = (root, val) =>{
1617
this.st.add(val);
17-
if(root.left != null) recover(root.left, val * 2 + 1)
18-
if(root.right != null) recover(root.right, val * 2 + 2)
18+
if(root.left != null) recover(root.left, val * 2 + 1)
19+
if(root.right != null) recover(root.right, val * 2 + 2)
1920
}
20-
21+
2122
recover(root, 0)
2223
};
2324

24-
/**
25+
/**
2526
* @param {number} target
2627
* @return {boolean}
2728
*/
2829
FindElements.prototype.find = function(target) {
2930
return this.st.has(target)
3031
};
3132

32-
/**
33+
/**
3334
* Your FindElements object will be instantiated and called as such:
3435
* var obj = new FindElements(root)
3536
* var param_1 = obj.find(target)
36-
*/
37+
*/

0 commit comments

Comments
 (0)