Dynamic Programming21 sections · 916 units
Open in Course

LeetCode 968 Binary Tree Cameras - Problem Statement

Minimum vertex cover variant

Place minimum cameras to monitor all nodes. A camera monitors itself, its parent, and its children. Three states per node: coveredcovered (no camera here but covered), hasCamerahasCamera, notCoverednotCovered (valid only if parent will cover).

Greedy intuition: place cameras at parents of leaves, not at leaves. Leaves are covered by their parents. DP captures this: leaves return "not covered", parents are forced to place cameras or be covered by their parents.