验证是否为二叉搜索树
const isValidBinarySearchTree = (tree) => {
const stack = [Number.MIN_VALUE];
const loop = (node) => {
if (node === null) return;
loop(node.left);
if (stack[stack.length - 1] >= node.value) return false;
stack.push(node.value);
loop(node.right);
return true;
};
return loop(tree);
};
以自己现在的努力程度,还没有资格和别人拼天赋

浙公网安备 33010602011771号