Maximize Subtree Product

Problem Overview

  • Given a tree with N nodes, cut one or more edges to split it into subtrees that maximize the product of their sizes.
  • Input: N and N-1 edges (U V); Output: the maximum product of subtree sizes after cuts.
  • Domain: graph/tree partitioning and network segmentation.
  • This Amazon interviews coding interview problem is a common interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: