← All problemsSign in

Find Distance

You will be given a tree represented by a matrix. The jth character of ith row will be 1 if there is a path from node i to j. You will also be given two integers N and F. N is the number of nodes in the tree and F(0 based index) is the node to which you need to find the distance from the root node. Root node will always be 0. Print the distance of the node F from the root. Input First line wi

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