AlgoDaily Solution
1Locked, only available for premium members.
Community Solutions
Community solutions are only available for premium users.
Access all course materials today
The rest of this tutorial's contents are only available for premium members. Please explore your options at the link below.
xxxxxxxxxx
90
var assert = require('assert');
function TreeNode(val) {
this.val = val
this.left = null
this.right = null
}
function columnNodesBinaryTree(root) {
// add your code here
return;
}
try {
let root = new TreeNode(3);
root.left = new TreeNode(9);
root.right = new TreeNode(20);
root.right.left = new TreeNode(15);
root.right.right = new TreeNode(7);
assert.deepEqual(columnNodesBinaryTree(root), [
[9],
[3, 15],
[20],
[7]
]);
console.log('PASSED: ' + "columnNodesBinaryTree([3, 9, 20, null, null, 15, 7]) should return `[[9], [3, 15], [20], [7]]`");
OUTPUT
Results will appear here.