← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Practice/Meta/Leetcode 1448. Count Good Nodes in Binary Tree
CodingOptional
Given the root of a binary tree, count the number of superior nodes in the tree.
A node is considered superior if its value is greater than or equal to all values encountered on the path from the root to that node (inclusive of the node itself).
The root node is always considered superior since there are no preceding nodes on its path.
Example 1:
`
Input: root = [3,1,4,3,null,1,5]
3
/
1 4
/ /
3 1 5
Output: 4
Explanation:
Example 2:
Input: root = [7] Output: 1 Explanation: A single node is always superior.
Example 3:
Input: root = [1,2,3] 1 / \ 2 3 Output: 3 Explanation: All nodes are superior since 2 >= 1 and 3 >= 1.