← All problemsSign in

Priyanshu and Family tree

Priyanshu was drawing his family tree and came up with an interesting problem. Given a tree with $n$ nodes and $n-1$ edges always rooted at $1$ . Each node $i$ has a number $A_i$ associated with it. You are given $Q$ queries to solve where in each query you will be given two numbers $x$ and $k$. **You have to find the sum of values of all the kth children of node x** . **If kth children of node

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