Tap here to switch tabs
Problem
Submissions

Problem: Count Dominant Nodes in a Binary Tree

Try to solve the Count Dominant Nodes in a Binary Tree problem.

Statement

Given the root of a complete binary tree, return the number of dominant nodes in the tree.

A node is considered dominant if its value is greater than or equal to the values of all nodes in its subtree.

Note: A subtree of a node consists of that node and all of its descendants.

Constraints:

  • The number of nodes in the tree is in the range [1,105][1, 10^5].

  • 1≤1 \leq Node.val ≤109\leq 10^9

  • The tree is guaranteed to be a complete binary tree.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Dominant Nodes in a Binary Tree

Try to solve the Count Dominant Nodes in a Binary Tree problem.

Statement

Given the root of a complete binary tree, return the number of dominant nodes in the tree.

A node is considered dominant if its value is greater than or equal to the values of all nodes in its subtree.

Note: A subtree of a node consists of that node and all of its descendants.

Constraints:

  • The number of nodes in the tree is in the range [1,105][1, 10^5].

  • 1≤1 \leq Node.val ≤109\leq 10^9

  • The tree is guaranteed to be a complete binary tree.