Tap here to switch tabs
Problem
Submissions

Problem: Count Nodes That Are Great Enough

Try to solve the Count Nodes That Are Great Enough problem.

Statement

Given the root of a binary tree and an integer k, a node is considered great enough if its subtree contains at least k nodes with values strictly less than node.val.

Return the total number of great enough nodes in the binary tree.

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,104][1, 10^4].

  • 1≤1 \leq Node.val ≤104\leq 10^4

  • 1≤1 \leq k ≤10\leq 10

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Nodes That Are Great Enough

Try to solve the Count Nodes That Are Great Enough problem.

Statement

Given the root of a binary tree and an integer k, a node is considered great enough if its subtree contains at least k nodes with values strictly less than node.val.

Return the total number of great enough nodes in the binary tree.

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,104][1, 10^4].

  • 1≤1 \leq Node.val ≤104\leq 10^4

  • 1≤1 \leq k ≤10\leq 10