← All problemsSign in

1261. Find Elements in a Contaminated Binary Tree

LeetCodeHash TableTreeDepth-First SearchBreadth-First SearchDesignBinary TreeOpen on judge ↗

Given a binary tree with the following rules: - root.val == 0 - For any treeNode: - If treeNode.val has a value x and treeNode.left != null, then treeNode.left.val == 2 * x + 1 - If treeNode.val has a value x and treeNode.right != null, then treeNode.right.val == 2 * x + 2 Now the binary tree is contaminated, which means all treeNode.val have been changed to -1. Implement the FindElements

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start