Question bank › Trees
Dsa Trees Medium

The Root-to-Leaf Power Grid

In a power distribution tree, the root provides electricity to various districts (leaves). Each transformer (node) and connection (edge) has an efficiency rating expressed as a percentage (0-100). When power passes through an edge, it is multiplied by (rating/100). Given the tree structure and efficiency ratings for each edge, find the path from the root (node 0) to any leaf that results in the highest remaining power percentage. Output the final percentage rounded to 4 decimal places. Input Format: Line 1: N (number of nodes) Next N-1 lines: u v R (parent node, child node, and efficiency percentage R) Example: Input: 3 0 1 90 0 2 50 Output: 90.0000

Key concepts

tree traversalpath productdepth-first search

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.