← All problemsSign in

AK and Two Trees

$A$ - You have to construct a integer sequence $X$ of length $N$. Where $-1 \leq X_i \leq 1$. $B$ - If the children in a rooted tree are given by $A_1, A_2, A_3, …. A_k$; the value $abs(X_{A_1} + X_{A_2} + ….. X_{A_k}) = 1$. You are given 2 such rooted trees $A$ and $B$ where each $A_i$ and $B_i$ are the values of their parent node and the value is $-1$ if the node is a root, you have to print i

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