Count nodes whose value is at least every value on the path from the root to that node. The root always qualifies.
Example 1
Argument 1 tree: level-order input; omitted children are null.root = [3,1,4,3,null,1,5]
4
Explanation
Root 3, the 3 beneath node 1, node 4 and node 5 qualify; both 1 nodes fail.
Example 2
Argument 1 tree: level-order input; omitted children are null.Explanation
Equality qualifies, so all three nodes of value 2 are good.
Example 3
Argument 1 tree: level-order input; omitted children are null.Explanation
A root has no greater ancestor and always qualifies.
Constraints
- 1 <= number of nodes <= 10000
- Values are -10000..10000
Function contractgoodNodesArguments: tree