Given a binary tree root, a node X is 'good' if in the path from the root to X, there is no node with a value greater than X's value. Return the number of good nodes.
Input: root = [3,1,4,3,null,1,5]
Output: 4
Topics: trees
Asked by: Amazon, Microsoft
Time complexity: O(n). Space complexity: O(h).