← 返回 meta 的题目列表Count Good Nodes in Binary Tree Based on Root Path Values
类型:online_judge
meta
Given a binary tree, find all 'good' nodes. A 'good' node is defined as a node where its value is greater than or equal to all the values from the root to that node.
Input
The root of a binary tree.
Output
An integer representing the number of 'good' nodes in the binary tree.
Example
Input: [3,1,4,3,null,1,5]
Output: 4
Constraints
The number of nodes in the tree is in the range [1, 10^4].
Each node's value is in the range [-10^4, 10^4].
Example
Input
[3,1,4,3,null,1,5]