← All problems

Count Good Nodes in Binary Tree

Medium treesdfs LeetCode ↗
Count nodes where the path from root contains no greater value.

Hints (0/3 revealed)

Log in to reveal hints progressively.

Complexity

Time O(n), Space O(h)

Common pitfalls

  • Using global max instead of path max
  • Strict vs non-strict comparison

Your solution

Log in to save your code and track progress.