Given the root of a binary tree, place the minimum number of cameras so that every node is monitored. A camera at a node monitors its parent, itself, and its immediate children. This is a standard tree DP problem because each node can be in one of several coverage states.
tree = level-order binary tree with null markers
minimum number of cameras
Example 1:
Input:
tree = [0,0,null,0,0]
Output:
1
Explanation:
A single camera at the left child can cover the root and both of its children.
Example 2:
Input:
tree = [0,0,0,null,null,0,0]
Output:
2
Explanation:
Two cameras are needed to cover both sides of the tree efficiently.