#1448 - Count Good Nodes in Binary Tree
Given the root of a binary tree, a node X is good if in the path from root to X there are no nodes with a value greater than X. Return the number of good nodes.
| Input | Output |
|---|---|
root = [3,1,4,3,null,1,5] | 4 |
root = [3,3,null,4,2] | 3 |
root = [1] | 1 |