-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBSTMaxSumPath.js
More file actions
40 lines (28 loc) · 925 Bytes
/
BSTMaxSumPath.js
File metadata and controls
40 lines (28 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// NOT FINISHED!!!!!
// Create class for BST Node
class BSTNode {
constructor(val=null, leftNode=null, rightNode=null) {
return this;
}
}
// Create class for Solution
// create function maxPathSum
// instantiate variable to return as our result
// Create edge case- if there are no nodes, return 0
// Create recursive calls for left and right side of the node
class Solution {
/**
* Return the sum value of the nodes on the max path within a given binary tree
* @param {BSTNode | Null} root root node of tree we will be traversing
* @returns {Number} Sum of the nodes' values on the max path
*/
maxSumPath(root=null) {
let res;
recursiveFunction = (rootNode=root) => {
// Base case
if (!rootNode) return 0;
// Recursive case
return "not finished"
}
}
}