Skip to content

#1448 - Count Good Nodes in Binary Tree

MediumBinary Tree - DFS
Open on LeetCode

Given the root of a binary tree, a node X is 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.

InputOutput
root = [3,1,4,3,null,1,5]4
root = [3,3,null,4,2]3
root = [1]1

Released under the MIT License.