Here is the description of this algorithm problem, and the input size are also listed below:
enter image description here
I am trying to solve it by dynamic programming on a tree, but can not come up with a good transition function.
New contributor
TrendMYX is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.