This problem requires us to point the next of the left node in each layer to the right node. Because it is processed layer by layer, it is very intuitive to think of using BFS to solve it.
This problem requires us to point the next of the left node in each layer to the right node. Because it is processed layer by layer, it is very intuitive to think of using BFS to solve it.
After reading the problem at the beginning, you can probably feel that DFS should be used to solve it. Use DFS to calculate the sum of each inform time from headID to a leaf, and finally take the maximum time.