TATA POWER Hiring Challenge | Count Nodes With the Highest Score Problem | On Campus OA(2024)

Question · Posted Jun 2026

Problem Statement You are given a rooted binary tree represented by an integer array parents of length n, where: parents[i] is the parent of node i The root node has parent -1 For every node i, remove that node and all edges connected to it. The tree breaks into zero or more connected components. The score of node i is defined as the product of the sizes of all non-empty components formed after removing that node. Your task is to ...

The full answer & interview discussion are available to premium members.

Log in Create a free account