Comparing backwards walks away from the target.
Acceptance criteria
- 1.#out should show found.
Comparing backwards walks away from the target.
const tree = { v: 2, left: { v: 1, left: null, right: null }, right: { v: 3, left: null, right: null } }; let node = tree, hit = false; while (node) { if (node.v === 3) { hit = true; break; } node = 3 < node.v ? node.right : node.left; } document.querySelector('#out').textContent = hit ? "found" : "missing";
Output ready when you are
Press Run to render your code, or Submit to validate your solution.