Given a tree with n nodes, each having a unique value, find the maximum width of the tree, where the width is defined as the maximum number of nodes at any level of the tree. The tree is represented as an adjacency list or array, and edges are given as pairs of node values.
Explanation: The tree has the following structure: 1 / \ 2 3 / \ / \ 4 5 6 7. The maximum width occurs at level 3 with 4 nodes.
Dynamic programming over tree structures
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak