← All problemsSign in

Split Tree

You are given a string $S$ in which each character is either $1$ or $0$. You are required to determine if a tree with $N$ vertices which satisfies the following conditions exist. Conditions: - Vertices are numbered 1 to $N$ - The edges are numbered 1 to $N$-1 and edge i connects vertex numbered a[i] and b[i] - If the i-th character in the string is $1$ then we must have a connected component of

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