first thought
- Selected 1…n as the root
- For each selection, the count is the multiplication of the count of it’s left sub tree and the right(DFS).
- The total sum of n is the sum of each selection.
- Using a array to cache the count of n.
solution
|
|
solution
|
|