Search
⌘K

Leetcode 1448. Count Good Nodes in Binary Tree

Count how many nodes in a binary tree are "good", meaning their value is at least the maximum value seen on the path from the root to that node. This is solved by a tree traversal (DFS/BFS) that carries the current path maximum and increments the count when a node's value >= that maximum; n up to 10^5.

Asked at:

Meta


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Mid December, 2025

Meta

Senior

Given a binary tree root, a node X in the tree is named good if in the path from root to X there are no nodes with a value greater than X. Return the number of good nodes in the binary tree.

Comments

Your account is free and you can post anonymously if you choose.