Post-order DFS. Return the state of each node. Count cameras (state nodes). Handle root specially: if root returns "not covered", we must add a camera at root. Null children: treat as "covered" (state ) so they don't force unnecessary cameras. Time: , Space: . Each node decides based on children's states in constant time. Start from leaves and work up. Leaves are never optimal camera locations because their parents cover more.
Time complexity: .
Space complexity: .