Adjacent Leaves
CodeChefOpen on judge ↗
Consider a rooted tree. A leaf in this tree is a vertex that does not have any children. Suppose that we perform a depth-first search from the root and write down the numbers of all leaves in the order in which they are visited. Since the order of visiting the sons of any vertex during the search is not fixed, many different sequences of leaves may be created. We call a subset of all leaves *good*
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.
Sign in to chat with the tutor and save your progress.
Sign in to start