Count the Leaves — Solution & Editorial
In the undirected representation a non-root leaf has degree exactly 1 — count such nodes (special-case N = 1).
Complexity: O(N)
In the undirected representation a non-root leaf has degree exactly 1 — count such nodes (special-case N = 1).
Complexity: O(N)