function rob(a, b, target) {
    var hash = {}
    var stack = [a]
    while (queue.length) {
        var node = stack.pop()
        stack[target - node.val] = 1;
        if (node.left) {
            stack.push(node.left)
        }
        if (node.right) {
            stack.push(node.right)
        }

    }
    var stack = [b]
    while (queue.length) {
        var node = stack.pop()
        if (stack[node.val] == 1) {
            return true
        }
        if (node.left) {
            stack.push(node.left)
        }
        if (node.right) {
            stack.push(node.right)
        }
    }
    return false
}

相关文章:

  • 2021-06-03
  • 2021-07-11
  • 2021-07-12
  • 2021-07-21
  • 2021-11-02
  • 2021-05-24
猜你喜欢
  • 2022-12-23
  • 2021-06-14
  • 2021-09-11
  • 2021-10-25
  • 2021-08-25
  • 2022-01-22
  • 2021-07-19
相关资源
相似解决方案