Ad

Help the wicked witch!!
Given a binary tree, return the id of the branch containing a poisoned apple.
Each node has the following structure:
Node: {
id: int
poisoned: true/false
left: Node
right: Node
}

If no poisoned apple on the tree return -1.

const findPoisoned = (node) => {
  // Help evil prevail !
  return node == null || node == undefined ? -1
    : node.poisoned ? node.id 
    : Math.max(findPoisoned(node.left),findPoisoned(node.right));
}