Back to DSA
Binary Tree Cameras
hardPlace surveillance cameras on the nodes of a binary tree so that every node is observed. A camera on a node covers that node, its parent, and its direct children. Determine the smallest number of cameras required to cover every node in the tree.
Examples
Example 1:
Input:
root = [0,0,null,0,null,0,0]Output:
2 Example 2:
Input:
root = [0,0,0]Output:
1Hints
1234567