← All problemsSign in

TREE AND FREQUENCY

$Saisha$ is playing with $TREES$. She has a tree of $N$ nodes rooted at $1$. Every node $i$ of the tree has $one$ candy of type $C_i$ attached with it. You need to tell $Saisha$, how many candies of type $Y$ are present in the sub-tree rooted at $X$. ###Input: - First line of input contains, two integers $N$, number of Nodes and $Q$, number of queries. - Next $N-1$ lines contain $U, V$

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