Problems > Count the Leaves > Editorial

Count the Leaves — Solution & Editorial

Back to the Problem

In the undirected representation a non-root leaf has degree exactly 1 — count such nodes (special-case N = 1).

Complexity: O(N)