Skip to content

Commit f4073b7

Browse files
committed
Time: 112 ms (37.33%), Space: 95.1 MB (64%) - LeetHub
1 parent 69ea237 commit f4073b7

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

2217-step-by-step-directions-from-a-binary-tree-node-to-another/2217-step-by-step-directions-from-a-binary-tree-node-to-another.js

+13-12
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,21 @@ var getDirections = function(root, startValue, destValue) {
3535
if (root == null) return null;
3636
if (root.val == startValue) pathArr[0]="U".repeat(path.length);
3737
if (root.val == destValue) pathArr[1]=path;
38+
if (pathArr[0]!=''&&pathArr[1]!='') return;
3839
findTarget(root.left, path+'L')
3940
findTarget(root.right, path+'R');
4041
}
4142

42-
function findStartValue (root, path='') {
43-
if (root == null) return null;
44-
if (root.val == startValue) return path;
45-
return (findStartValue(root.left, path+'U') ||
46-
findStartValue(root.right, path+'U'));
47-
}
48-
function findEndVal (root, path='') {
49-
if (root == null) return null;
50-
if (root.val == destValue) return path;
51-
return (findEndVal(root.left, path+'L') ||
52-
findEndVal(root.right, path+'R'));
53-
}
43+
// function findStartValue (root, path='') {
44+
// if (root == null) return null;
45+
// if (root.val == startValue) return path;
46+
// return (findStartValue(root.left, path+'U') ||
47+
// findStartValue(root.right, path+'U'));
48+
// }
49+
// function findEndVal (root, path='') {
50+
// if (root == null) return null;
51+
// if (root.val == destValue) return path;
52+
// return (findEndVal(root.left, path+'L') ||
53+
// findEndVal(root.right, path+'R'));
54+
// }
5455
};

0 commit comments

Comments
 (0)