1448. Count Good Nodes In Binary Tree
Practice Count Good Nodes In Binary Tree for free on NudgeCode: Medium, Binary Tree pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
A node is good if no node on the path from the root down to it has a larger value. Return the number of good nodes in the tree. The root is always good.
Example
root = [3,1,4,3,null,1,5] -> 4 (3, 4, 5 and the lower 3)
Constraints
- 1 <= number of nodes <= 10^5
- -10^4 <= Node.val <= 10^4