function dfs2(node, target, hashmap) {
  if (!node) {
    return false;
  }

  if (hashmap[target - node.val]) {
    return true;
  }

  hashmap[node.val] = true;

  return dfs2(node.left, target, hashmap) || dfs2(node.right, target, hashmap);
}
// second try with better memory usage
second try with better memory usage
second try with better memory usage
function dfs2(node, target, hashmap) {
  if (!node) {
    return false;
  }
  if (hashmap[target - node.val]) {
    return true;
  }
  hashmap[node.val] = true;
  return dfs2(node.left, target, hashmap) || dfs2(node.right, target, hashmap);
}
function dfs2 ( node , target , hashmap ) { if ( ! node ) { return false ; } if ( hashmap [ target - node . val ] ) { return true ; } hashmap [ node . val ] = true ; return dfs2 ( node . left , target , hashmap ) || dfs2 ( node . right , target , hashmap ) ; }
second try with better memory usage
second try with better memory usage